predicate

How to list all predicates that has an specific atom?

大憨熊 提交于 2019-12-01 00:04:49
another way to ask the question is: How I can list all the properties of an atom? For example: movie(agora). director(agora, 'Alejandro Amenabar') duration(agora, '2h'). so, I will like to receive all the predicates that has agora for argument. In this case it will be: movie, director, duration, with the other parameters ('Alejandro Amenabar', '2h'). I found: this , and this questions, but I couldn't understand well. I want to have value of false in the "variable Answer" if PersonInvited doesn't like something about the movie. My query will be: answer(Answer, personInvited,

Combining Predicates

谁都会走 提交于 2019-11-30 20:41:27
Is there any way that you can combine predicates? Lets say I have something like this: class MatchBeginning : public binary_function<CStdString, CStdString, bool> { public: bool operator()(const CStdString &inputOne, const CStdString &inputTwo) const { return inputOne.substr(0, inputTwo.length()).compare(inputTwo) == 0; } }; int main(int argc, char* argv[]) { CStdString myString("foo -b ar -t az"); vector<CStdString> tokens; // splits the string every time it encounters a "-" split(myString, tokens, "-", true, true); vector<CStdString>::iterator searchResult = find_if(tokens.begin(), tokens

std::remove_if using other class method

早过忘川 提交于 2019-11-30 19:18:55
问题 I want to use std::remove_if with a predicate that is a member function of a differenct calss. That is class B; class A { bool invalidB( const B& b ) const; // use members of class A to verify that B is invalid void someMethod() ; }; Now, implementing A::someMethod , I have void A::someMethod() { std::vector< B > vectorB; // filling it with elements // I want to remove_if from vectorB based on predicate A::invalidB std::remove_if( vectorB.begin(), vectorB.end(), invalidB ) } Is there a way to

How to list all predicates that has an specific atom?

梦想与她 提交于 2019-11-30 18:50:01
问题 another way to ask the question is: How I can list all the properties of an atom? For example: movie(agora). director(agora, 'Alejandro Amenabar') duration(agora, '2h'). so, I will like to receive all the predicates that has agora for argument. In this case it will be: movie, director, duration, with the other parameters ('Alejandro Amenabar', '2h'). I found: this, and this questions, but I couldn't understand well. I want to have value of false in the "variable Answer" if PersonInvited doesn

Combine XPATH predicate with position

会有一股神秘感。 提交于 2019-11-30 14:06:24
问题 I have a collection of div elements that have the class media-gallery-item . I would like to select element number x. When just selecting all items, I get 5 results $x("//div[@id='content-area']//div[@class='media-gallery-item']") Now I want to be able to select item number 2, but I can't figure out how to combine the two properly: $x("//div[@id='content-area']//div[@class='media-gallery-item'][2]") $x("//div[@id='content-area']//div[@class='media-gallery-item' and position() = 2]") I know

Prolog: How to tell if a predicate is deterministic or not

为君一笑 提交于 2019-11-30 13:30:50
So from what I understand about deterministic predicates: Deterministic predicate = 1 solution Non-deterministic predicate = multiple solutions Are there any type of rules as to how you can detect if the predicate is one or the other? Like looking at the search tree, etc. There is no clear, generally accepted consensus about these notions. However, they are usually based rather on the observed answers and not based on the number of solutions. In certain contexts the notions are very implementation related. Non-determinate may mean: leaves a choice point open. And sometimes determinate means:

Combine XPATH predicate with position

五迷三道 提交于 2019-11-30 09:39:22
I have a collection of div elements that have the class media-gallery-item . I would like to select element number x. When just selecting all items, I get 5 results $x("//div[@id='content-area']//div[@class='media-gallery-item']") Now I want to be able to select item number 2, but I can't figure out how to combine the two properly: $x("//div[@id='content-area']//div[@class='media-gallery-item'][2]") $x("//div[@id='content-area']//div[@class='media-gallery-item' and position() = 2]") I know these don't make a lot of sense since it's not an actual AND , but more like: "filter according to this

C#, Linq2SQL: Creating a predicate to find elements within a number of ranges

谁说胖子不能爱 提交于 2019-11-30 09:16:28
Lets say I have something called Stuff in my database, with a property called Id. From the user I get a sequence of selected Range objects (or rather I create them from their input) with the Ids they want. A stripped down version of that struct looks like this: public struct Range<T> : IEquatable<Range<T>>, IEqualityComparer<Range<T>> { public T A; public T B; public Range(T a, T b) { A = a; B = b; } ... } So one could for example have gotten: var selectedRange = new List<Range<int>> { new Range(1, 4), new Range(7,11), }; I then want to use that to create a predicate to select only things

How can pointers be totally ordered?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 06:39:37
Pointers in C++ may in general only be compared for equality. By contrast, less-than comparison is only allowed for two pointers that point to subobjects of the same complete object (e.g. array elements). So given T * p, * q , it is illegal in general to evaluate p < q . The standard library contains functor class templates std::less<T> etc. which wrap the built-in operator < . However, the standard has this to say about pointer types (20.8.5/8): For templates greater , less , greater_equal , and less_equal , the specializations for any pointer type yield a total order, even if the built-in

List<object>.RemoveAll - How to create an appropriate Predicate

爷,独闯天下 提交于 2019-11-30 05:36:15
This is a bit of noob question - I'm still fairly new to C# and generics and completely new to predicates, delegates and lambda expressions... I have a class 'Enquiries' which contains a generic list of another class called 'Vehicles'. I'm building up the code to add/edit/delete Vehicles from the parent Enquiry. And at the moment, I'm specifically looking at deletions. From what I've read so far, it appears that I can use Vehicles.RemoveAll() to delete an item with a particular VehicleID or all items with a particular EnquiryID. My problem is understanding how to feed .RemoveAll the right