http://t3x.org/mcl/prolog.html   (light|dark)

MICRO COMMON LISP

A Tiny PROLOG

This is a REPL session with MICRO COMMON LISP running a slightly modified version of Ken Kahn's tiny PROLOG from the SAIL AIList Digest V1, #47, 1983.

MICRO COMMON LISP 03
5116 NODES

* (load "src/prolog")
T

* (gc)
4168   ; 5116-4168 = 948 nodes, a rather small program

; This is the PROLOG program
; append([], L, L).
; append([X|XS], YS, [X|ZS]) :- append(XS, YS, ZS).

* *db*
(((APPEND NIL (\ L) (\ L)))
 ((APPEND ((\ X) . (\ XS)) (\ YS) ((\ X) . (\ ZS)))
  (APPEND (\ XS) (\ YS) (\ ZS))))

; what is (A B C) appended to (D E F)?

* (prolog *db* '(append (a b c) (d e f) (\\ x)))

X = (A B C D E F) 
NIL

; what A can be appended to what B to give (A B C)?

* (prolog *db* '(append (\\ a) (\\ b) (a b c))) 

B = (A B C) 
A = NIL 

B = (B C) 
A = (A) 

B = (C) 
A = (A B) 

B = NIL 
A = (A B C) 
NIL

*

contact | privacy