Read on for more.
Often in a TEC rule, you need to do something similar to the following (pseudocode):
if (A()) then
B(),
C()
endif
D(),
E()
Essentially, you only want to do B() and C() if A() is true, but you ALWAYS want to do D() and E(), whether A(), B() or C() returns true. There are several ways to code this without the use of findall(), but I think the code is much cleaner when using findall(), as shown here:
findall(_,(A(),B(),C()),_),
D(),
E()
The findall() predicate executes the specified predicate (or group of predicates) and builds a list, which is returned as the last parameter provided. A consequence of this is that findall() ALWAYS returns true, even if A(), B() or C() fails.
No comments:
Post a Comment