Script started on Fri May 16 13:42:31 1997 % cl Allegro CL 4.1 [DEC MIPS; R1] (9/21/92 16:49) Copyright (C) 1985-1992, Franz Inc., Berkeley, CA, USA. All Rights Reserved. ;; Optimization settings: safety 1, space 1, speed 1, debug 2 ;; For a complete description of all compiler switches given the current ;; optimization settings evaluate (EXPLAIN-COMPILER-SETTINGS). USER(1): (quote (a b c)) (A B C) USER(2): (reverse '(a b c)) (C B A) USER(3): (cond ((= 1 2) 3) (4 5) (t 6)) 5 USER(4): (equal '(worm slug) '(worm slug)) T USER(5): (eq '(worm slug) '(worm slug)) NIL USER(6): (mapcar #'(lambda (x) x) '(worm slug snail)) (WORM SLUG SNAIL) USER(7): (car (cdr (cdr '(1 2 3 4 5 6 7 8)))) 3 USER(8): (cdr (car (car '(1 2 3 4 5 6 7 8)))) Error: Attempt to take the car of 1 which is not a cons. [condition type: SIMPLE-ERROR] USER(9): (+ (length '(1 2)) 7 'cow)) Error: COW is an illegal argument to + [condition type: TYPE-ERROR] USER(10): (defun snork (L) (cond ((null L) L) ((null (cdr L)) L) (t (cons (car (cdr L)) (cons (car L) (snork (cdr (cdr L)))))))) SNORK USER(11): (snork '(1 2 3 4 5 6 7 8 9 10)) (2 1 4 3 6 5 8 7 10 9) USER(12): (snork '(1 2 3 4 5 6 7 8 9 )) (2 1 4 3 6 5 8 7 9) USER(13): (lambda (x) (+ x 1)) 1) Error: attempt to call `LAMBDA' which is an undefined function. [condition type: UNDEFINED-FUNCTION] ;; Oops a paren go lost - this is what I meant: USER(14): ((lambda (x) (+ x 1)) 1) 2 USER(15): (and (= 1 2) (+ 'bob tom)) NIL USER(16): (defun bob (bill jill) (list jill bill)) BOB USER(17): (setq bob 'rob) ROB USER(18): (bob 'bob bob) (ROB BOB) USER(21): (defun every-other (L) (cond ((null L) nil) ((null (cdr L)) nil) (t (cons (cadr L) (every-other (cddr L)))))) EVERY-OTHER USER(22): (every-other '(1 2 3 4 5 6 7 8)) (2 4 6 8) USER(23): (defun increasing (L) (cond ((null L) t) ((null (cdr L)) t) ((> (car L) (cadr L)) nil) (t (increasing (cdr L))))) INCREASING ;; Of course you can use the following functions instead ;; of the traditional ones: ;; (car L) => (first L) ;; (cdr L) => (rest L) ;; (cadr L) => (second L) ;; (cddr L) => (rest (rest L)) USER(24): (increasing '(1 1 2 3 4 5 5 6 7 8 )) T USER(25): (increasing '(1 2 3 4 3 4 5)) NIL USER(26): ^D Really exit lisp [n]? y ; Exiting Lisp % script done on Fri May 16 13:55:22 1997 ========================================= Script started on Fri May 16 14:48:59 1997 lynx% prolog Quintus Prolog Release 3.1 (DECstation, Ultrix 4.x) Copyright (C) 1990, Quintus Corporation. All rights reserved. 2100 Geng Road, Palo Alto, California U.S.A. (415) 813-3800 | ?- [q2]. % compiling file /Sucia/staff/anderson/plog/q2 % q2 compiled in module user, 0.183 sec 1,836 bytes | ?- rank(A, assoc, _), dept(A, math). A = erdos ; A = euler ; no | ?- chair(_, A), rank(A, B, _). A = newton, B = full ; A = euler, B = assoc ; A = vonNeumann, B = full ; no // colleague(P1, P2) :- dept(P1, Dept), dept(P2, Dept). | ?- colleague(einstein, A). A = newton ; A = einstein ; A = feynman ; no // boss(Chair, Prof) :- chair(Dept, Chair), dept(Prof, Dept). | ?- boss(A, turing). A = euler ; A = vonNeumann ; no // highPay(P1) :- boss(P2, P1), rank(P2, _, S2), rank(P1,_,S1), S1 > S2. | ?- highPay(A). A = einstein ; no | ?- highPay(A), boss(A,_). no // Now if we add the fact dept(physics, vonNeumann), we get // the result that vonNeumann is a highly paid chairman, since vonNeumann // is paid more than the chairman of the physics department | ?- highPay(A), boss(A,_). A = vonNeumann ; A = vonNeumann ; A = vonNeumann ; A = vonNeumann ; no //shift(L1,L2) :- append(A,B,L1), append(B,A,L2). | ?- shift([1,2,3,4], [3,4,1,2]). yes | ?- shift([2,1,3,4], [1,2,3,4]). no | ?- shift([1,2,3,4], [1,2,3]). no | ?- shift(A, [1,2,3,4]). A = [1,2,3,4] ; A = [4,1,2,3] ; A = [3,4,1,2] ; A = [2,3,4,1] ; A = [1,2,3,4] ; // and now it goes into an infinite loop . . . | ?- shift([1,2,3,4], A). A = [1,2,3,4] ; A = [2,3,4,1] ; A = [3,4,1,2] ; A = [4,1,2,3] ; A = [1,2,3,4] ; no // eo([],[]). // eo([_],[]). // eo([_,Y|L1], [Y|L2]) :- eo(L1, L2). | ?- eo([1,2,3,4,5], A). A = [2,4] ; no | ?- eo([1,2,3,4,5], [1,3,5]). no | ?- eo([1,2,3,4,5], [2,4]). yes | ?- eo(A, [2,4]). A = [_9289,2,_9293,4] ; A = [_9289,2,_9293,4,_9297] ; no