Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document :exists #33

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions _docs/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ This will generate a rule that fires if the Customer fact has a vip status, **or

For further information, see [Boolean Expressions](/docs/booleans).

## Exists Expressions

_:exists_ tests the existence or absence of facts without triggering for every fact instance. For example:

{% highlight clojure %}
[:exists [Person (= name "Bob")]]
{% endhighlight %}

This will trigger the _first_ time a Person with the name "Bob" is inserted, but not the second or third. It will only retract after all supporting facts are removed.

eraserhd marked this conversation as resolved.
Show resolved Hide resolved
Unbound variables are treated the same as in [accumulators](/docs/accumulators/); the :exists rule will trigger once for each distinct set of unbound values.

## Tests
![test expression](/img/diagram/TEST_EXPR.png)

Expand Down