Questions tagged [predicates]

Predicates are functions that return the boolean values, `True` or `False`.

In computing, Predicates are functions that return the boolean values, True or False. Some languages and frameworks treat them specially.

See also Wikipedia.

There are alternate (and possibly more mainstream) meanings. See Wikipedia.

108 questions
1
vote
1 answer

ANTLR -- use predicates to insert a token

I am trying to understand ANTLR predicates. To that end, I have a simple lexer and parser, shown below. What I would like to do is use a predicate to insert the word "fubar" every time it sees "foo" followed by some whitespace and then "bar". I…
William Jockusch
  • 26,513
  • 49
  • 182
  • 323
1
vote
2 answers

Duplicate Entries for A Core Data Table View Controller and How To Handle This With NSFetchedResultsController

I have a simple application with the following premise and a few minor issues: I have 4 Tabs, each with a table view displaying different information and each with a plus button going modally to the same view controller, allowing users to add in…
amitsbajaj
  • 1,304
  • 1
  • 24
  • 59
1
vote
1 answer

Prolog predicates

I am currently learning about predicate logic in Prolog. I am having trouble answering a question on the topic and would like to know the steps one one take to solve such a question using Prolog predicates. I have a scenario which must be…
DrKhan
  • 313
  • 1
  • 3
  • 10
1
vote
3 answers

Finding the most similar list from predicate knowledge base in Prolog

I have a problem in which I have a list of elements and I have to cycle through all instances of a particular /2 predicate to find which one has he highest number of matching elements in its list. In terms of implementation I can't seem to figure…
user2211776
  • 239
  • 1
  • 2
  • 11
1
vote
2 answers

Can CoreData return unique entity attributes?

Lets say I have an entity with an attribute called animalType. Within core data I have 10,000 of these entities and there are an unknown amount of different animal types, Eg. dog, cat, bird, etc. Can I tell core data to fetch each animal type and…
NSWill
  • 659
  • 8
  • 15
1
vote
1 answer

Core data predicates with key-paths

So i'm trying to work out how to use these predicates, i've read the Apple doc and am trying to use it (https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/Articles/pUsing.html) and i have the predicate set up, but it…
Craig
  • 556
  • 1
  • 8
  • 23
1
vote
1 answer

Building dynamic lambda predicate with short date

I have the following code that helps me build a lambda expression via reflection. However when I try to compare versus a Date it converts my value to a full DateTime stamp. How can I get it to build my predicate so it will only compare the short…
UnHoly Ram
  • 157
  • 1
  • 9
1
vote
1 answer

Using ANTLR, how do I handle specific repeats without using language specific semantic predicates?

I am trying to model mqsi commands, using ANTLR and have come across the following problem. The documents for mqsicreateconfigurableservice say for the queuePrefix : "The prefix can contain any characters that are valid in a WebSphere® MQ queue…
Greg
  • 195
  • 1
  • 13
0
votes
2 answers

What is the meaning of predicate "simple/1" in Prolog (SWI-Prolog)

I run into problem while reading a book. I see a program use predicate "simple" ( I guess simple/1 ). I don't know what is the meaning of this predicate, I can't find it with ?-help(simple) in the console. But when I tried with some queries in…
toantran
  • 1,789
  • 17
  • 25
0
votes
1 answer

look for json key's value in jsonb

i am using criteriabuilder of jpa and i want to look for a value of a json field in a jsonb column. the jsonb looks like this : [{"field1":"value1","field2":"value2"},{"field3":"value3","field4":"value4"}] i started creating my predicates but i…
M.Simon
  • 11
  • 9
0
votes
2 answers

XSLT: Difference between using predicates and statement

I am trying to understand if there is any difference between using predicates and using an ? From a performance perspective, is the use of a predicate any better? Does predicates also traverse through each node in the xml tree to identify…
Thani
  • 13
  • 1
0
votes
0 answers

Semantic Predicate affected scope

please consider the following grammar which gives me unexpected behavior: lexer grammar TLexer; WS : [ \t]+ -> channel(HIDDEN) ; NEWLINE : '\n' -> channel(HIDDEN) ; ASTERISK : '*'…
J. Nagel
  • 1
  • 2
0
votes
1 answer

Prolog Recursive Predicates

Give recursive definition in Prolog: Define a predicate that holds of an argument X if and only if X is a list and the length of X is odd. I have been trying to solve this for ages. I am just wanting to learn ProLog for myself and found this problem…
user9714805
0
votes
1 answer

How can semantic predicates use early information from listeners with ANTLR 4?

I have a parser based on ANTLR 4 and using listeners, not visitors. It already recognizes and stores the declaration of functions, variables and so on. I'm trying to resolve some grammar ambiguities with semantic predicates, for instance to separate…
RedGlyph
  • 11,309
  • 6
  • 37
  • 49
0
votes
1 answer

Map SQL on Predicates

I have some SQL select id, name from table where id = '1' and name = 'A' or id = '2' and name = 'B' or id = '3' and name = 'C'; Result of SQL satisfies me, but anyway I have to map…
Oleh Linnyk
  • 59
  • 1
  • 13