/ Published in: Lisp
This demonstrates, in as few lines as possible, the basic syntax of LISP. You should be able to figure out how to make more complex programs just by thinking about it. For example, if (+ '1 '2) is how you add numbers, then (* '1 '2) would multiply numbers. String them together for more complexity --- (* (+ '1 '2) (+ '3 '4)). Note that, with numbers, you can use '1 or 1 -- it's basically the same thing. With variables, it is different. Designed using CLISP.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(print 'hi) (print "hello world") (defun f(x) (cond ((null x) 'null) ('T 'not-null) ) ) (f 'blah) (f NIL) (defun g() (print 'hi) (print 'bye) ) (g) (setq x 5) (equal x 5) (print x) (print 'x) (+ '5 '3) (if 'T 1 2) (if NIL 1 2) (and 'T 'T) (or 'T NIL) (if (and 'T 'T) 1 2) (car '(1 2 3 4 5)) (cdr '(1 2 3 4 5))