predicate

NSPredicate not working with calculated field

被刻印的时光 ゝ 提交于 2019-12-06 12:34:39
I have a Core Data project and am having difficulty searching the data with a simple calculated field and have no idea why it's not working. I have a Tutor entity, with core data string attributes "tutorFirstName" and "tutorLastName". I've created an additional string attribute "tutorFullName" which is populated in a Category as such: NSString *fullName = [@[self.tutorFirstName, self.tutorLastName] componentsJoinedByString:@" "]; The data is populated fine, but when I perform the following searches only the predicates on the tutorFirstName and tutorLastName work: NSPredicate *predicate =

Displaying Core Data: If attribute has same name display once

余生长醉 提交于 2019-12-06 12:29:01
I have viewed numerous predicate questions, I have read the docs and nothing seems to be jumping out as an answer my problem. I have a Core Data entity named Materials and I have the Attributes category , subcategory and description . I have three UITableViewControllers and in each I want to use a predicate to display as follows: TableViewController 1: Only the categories (no repeating of category names) Select a category and go to TableViewController 2. TableViewController 2: Display Subcategories (no repeating of subcategory names) Select a subcategory and go to TableViewController 3 listing

sigabrt on filteredArrayUsingPredicate

可紊 提交于 2019-12-06 12:07:35
问题 I'm a noob and trying to convert an example from a book into an app I can use. The sample app is a modified version of the contacts application and it works. I've done some further modification, and the search no longer works. It sigabrts on the following line self.filteredAnswercards = [flattenedArray filteredArrayUsingPredicate:predicate]; I'm stumped. my head is bloody from beating it against my keyboard. ANY help is massively appreciated. Thanks. 回答1: My suggestion was to wrap the line

EntityFramework Casting issues

假如想象 提交于 2019-12-06 11:21:43
问题 I am building my query using PredicateBuilder from LinqKit. it is great and does exactly what i am looking for. To make my code more reusable (tables and views) i created a generic predicate builder class: public class LocalPredicateBuilder<T> where T : IResort ... var predicate = PredicateBuilder.True<T>( which exposes BuildPredicate method. I can use it like this: var predicate = new LocalPredicateBuilder<Resort>().BuildPredicate(); var resorts = _entities.Resorts.Where(predicate).ToList();

How to implement a Predicate in Java used for cross-checking a String against an arbitrary amount of rules?

ぐ巨炮叔叔 提交于 2019-12-06 08:27:05
This question is a continuation of: How to check whether an input conforms to an arbitrary amount of rules in Java? I'm trying to make use of Predicates to cross-check a string/word against a set of rules/methods that return a boolean value. However I'm having difficulties implementing it in my code. public class CapValidator { /** PRIMARY METHODS **/ private boolean capitalize(String word) { // boolean valid = true; // for (Predicate<> rule : rules) { // valid = valid && rule.test(word); // } return false; } /** SUPPORT METHODS **/ private boolean isNoun(String word) { // do some logic }

Prolog — symetrical predicates

半腔热情 提交于 2019-12-06 08:14:13
问题 I have to simulate family tree in prolog. And i have problem of symetrical predicates. Facts: parent(x,y). male(x). female(y). age(x, number). Rules: blood_relation is giving me headache. this is what i have done: blood_relation(X,Y):-ancestor(X,Y). blood_relation(X,Y):-uncle(X,Y);brother(X,Y);sister(X,Y);(mother(Z,Y),sister(X,Z));(father(Z,Y),sister(X,Z));(father(Z,Y),brother(X,Z)). blood_relation(X,Y):-uncle(X,Z),blood_relation(Z,Y). and I am getting i think satisfactory results(i have

Passing a parameter to a linq predicate

旧街凉风 提交于 2019-12-05 23:07:13
I want to write code like the following - public IQueryable<Invoice> InvoiceFilterForMonthAndYear(DateTime? monthAndYear = null) { var invoices = _invoices.Where(MonthAndYearPredicate(monthAndYear); return invoices; } private bool MonthAndYearPredicate(Invoice invoice, DateTime? monthAndYear) { //code to check if the invoice start or end dates is from the falls in the month I am checking for } But I can't use a predicate like that because the predicate expects just one parameter. I know I could write a Where clause in InvoiceFilterForMonthAndYear to do the work, but I want to put the logic for

Can you implement any pure LISP function using the ten primitives? (ie no type predicates)

旧街凉风 提交于 2019-12-05 18:08:33
问题 This site makes the following claim: http://hyperpolyglot.wikidot.com/lisp#ten-primitives McCarthy introduced the ten primitives of lisp in 1960. All other pure lisp functions (i.e. all functions which don't do I/O or interact with the environment) can be implemented with these primitives. Thus, when implementing or porting lisp, these are the only functions which need to be implemented in a lower language. The way the non-primitives of lisp can be constructed from primitives is analogous to

Finding elements in a scala list and also know which predicate has been satisfied

拜拜、爱过 提交于 2019-12-05 17:19:38
问题 I have the following problem in scala. I have to find the first element in al list which satisfies a predicate function with two conditions in OR. The problem is that I would like to get the element but also know which of the two conditions has been satisfied. Here is a simple example: val l1 = List("A", "B", "AA", "BB") val l2 = List("AA", "BB", "A", "B") def c1(s: String) = s.startsWith("B") def c2(s: String) = s.length == 2 println(l1.find(s => c1(s) || c2(s))) println(l2.find(s => c1(s) |

How to prioritize/rank FilteredList results within a predicate?

别来无恙 提交于 2019-12-05 14:21:46
My application contains a TextField and a ListView . The TextField allows users to enter search terms that will filter the contents of the ListView as they type. The filtering process will match several fields within each DataItem in the ListView and return the results if any of them match. What I want to do, however, is have those results prioritize items that match one particular field over the others. For example, in the MCVE below, I have two items: Computer and Paper . The Computer item has a keyword for "paper," so searching for "paper" should return Computer as a result. However, since