All Manuals > KnowledgeWorks and Prolog User Guide > A Common Prolog > A.5 Accessing Lisp From Common Prolog

NextPrevUpTopContentsIndex

A.5.1 Examples

|==> ((print "foo"))
|
|"foo"
|YES.
|
|==> (and (= ?x 3) ((* ?x ?x) ?y)) 
                 ; Note that "?y" is unified with 9
|?X = 3
|?Y = 9
|
|==> ((* 3 3) 10)
|NO.
|
|==> ((floor 3 4) ?x ?y)
|
|?X = 0
|?Y = 3
|==> ((floor 3 4) ?x)
|
|?X = 0
|
|==> ((* 3 4) ?x ?y)
|
|?X = 12
|?Y = ?0   
  ; note that system generated variables look like:
  ; ?<integer>
|==> ((typep 3 'integer) ?x)
|
|?X = T
|
|==> ((typep 3 'integer) t)
|
|YES.
|
|==> (and ((floor 5 3) ?x) ((floor 4 3) ?x))
|
|?X = 1
|
|==> ((cons 3 4) (?x . ?y))
|
|?X = 3
|?Y = 4
|
|==> (and (= ?op *) ((list ?op 3 4) ?y) (call (?y ?z)))
|
|?OP = *
|?Y = (* 3 4)
|?Z = 12
|
|==> (and (defrel fact
|           ((fact 0 1))
|           ((fact ?x ?y)
|            ((- ?x 1) ?w)
|            (fact ?w ?z)
|            ((* ?z ?x) ?y)))
|         (fact 10 ?result))
|
|?X = ?0
|?Y = ?1
|?W = ?2
|?Z = ?3
|?RESULT = 3628800

KnowledgeWorks and Prolog User Guide (Windows version) - 24 Mar 2017

NextPrevUpTopContentsIndex