Match Iterators


The matcher iterators area small suite of functions/macros which iterate one or more patterns over a set of lists. They come in two flavours, IS-PRESENT and FOREACH work with a single patten, ALL-PRESENT and FOREVERY work with multiple patterns.


Examples using IS-PRESENT and ALL-PRESENT...

> (is-present ( '(isa ?obj cat)
                '((isa fido dog)
                  (isa felix cat)
                  (isa tom cat)
                  (isa lassie dog))
               )
      (match-bind '(found a cat called ?obj)))

==> (FOUND A CAT CALLED FELIX)
 
 

> (all-present ( '((isa ?obj cat) (chases ?obj ?thing))
                 '((isa fido dog)
                   (chases tom jerry)
                   (chases felix spike)
                   (isa felix cat)
                   (isa tom cat)
                   (isa lassie dog))
                )
      (match-bind '(found a cat called ?obj chasing ?thing)))
==> (FOUND A CAT CALLED FELIX CHASING SPIKE)