Lisp Part One

Page content

Lisp Part One

Using SBCL (Steel Bank common Lisp) on Debian

simple stuff

* (quote (was ist den hier los))
(WAS IST DEN HIER LOS)		;;Das ist einen Liste

* '(was ist den hier los)
(WAS IST DEN HIER LOS)		;;Auch eine Liste

* '(was ist (denn hier) los)	;;Verschachtelte Liste
(WAS IST (DENN HIER) LOS)

* '(die "Antwort" ist 42)
(DIE "Antwort" IST 42)

* '(+ 1 2 3 4 5)
(+ 1 2 3 4 5)			;;Liste

* (+ 1 2 3 4 5)			;;Addition
15

* (defun dbl (n) (* 2 n)
DBL

Usefull Stuff

* (mapcar 'dbl '(1 2 3 4))	;;applies our function to a list
(2 4 6 8)

(set 'ding '(auto (marke "VW") (baujahr 1981) (gewicht (894 kg))))
(AUTO (MARKE "VW") (BAUJAHR 1981) (GEWICHT (894 KG)))

(mapcar 'second (rest ding))		;;AUTO is not of type list, that's why we remove it with rest
("VW" 1981 (894 KG))		        ;;gives the 2nd element of each list entry