Learning Pilog — 7: Cuts and Negations

What is a “Cut”?

: (? (maxi 5 1 5))
-> T
: (? (maxi 2 3 2))
-> NIL
: (? (maxi 2 3 5))
-> NIL
: (? (maxi 2 3 @Max))
@Max=3
-> NIL
  • the ^ symbol in the CAR,
  • the PicoLisp program body in the CDDR,
  • the variable to which the result is unified in the CADR.
(be maxi (@X @Y @Y)
(^ @ (<= @X @Y)) )
(be maxi (@X @Y @X)
(^ @ (> @X @Y)) )
(be maxi (@X @Y @Y)
(^ @ (<= @X @Y))
T)

Negation as a failure

# Mary likes all animals except insects.
(be likes (Mary @X)
(insect @X)
T
(fail) )
(be likes (Mary @X)
(animal @X) )
(be animal (@X) (insect @X))
(be animal (@X) (pet @X))
(be animal (@X) (cattle @X))
(be insect (Spider))
(be pet (Cat))
(be pet (Dog))
(be cattle (Cow))
: (? (likes Mary Cat))
-> T
: (? (likes Mary Spider))
-> NIL

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mia Temma

Mia Temma

These are cross-posts from my blog https://picolisp-explored.com. I’m writing about PicoLisp for beginners. Welcome!