, LISPy, - / . - , .
, -, , :
:
'()? ( - null)'(a)? ( - a, , , )'((a))? ( - (a))'(anything), - ? ( - (first anything))'(anything morestuff)? ( - (cons (first anything) (first-element morestuff)))- ? , ( ).
- null?
nil. - ?
(car list)
:
;; here first, meeting questions 6-8
(define first (lambda (l)
(cond
((null? l) nil) ; Q7
((atom? l) l) ; Q6
(t (car l))))) ; Q8
;; with first we can write first-element, meeting questions 1-5
(define first-element (lambda (l)
(cond
((null? l) nil) ; Q1
((atom? l) (first l)) ; Q2
(t (cons (first (car l) (first-element (cdr l)))))))) ; Q4-5
(). , . , , .
MAPCAR? . . MAPCAR. ? . Dang LISP/ , .
, , . " foo ?" : null? ? ? ? , , foo. foo on null? foo ? foo ?