22 lines
564 B
Common Lisp
22 lines
564 B
Common Lisp
|
(defun mapcar (function-name the-list)
|
||
|
(if the-list
|
||
|
(cons
|
||
|
(funcall function-name (first the-list))
|
||
|
(mapcar function-name (rest the-list)))))
|
||
|
|
||
|
(defun maplist (function-name the-list)
|
||
|
(cond
|
||
|
((null the-list) nil)
|
||
|
(t (cons (funcall function-name the-list)
|
||
|
(maplist function-name (rest the-list))))))
|
||
|
|
||
|
(defun append (listA listB)
|
||
|
(cond
|
||
|
((null listA) listB)
|
||
|
(t (cons (first listA) (append (rest listA) listB)))))
|
||
|
|
||
|
(defun nth (n listA)
|
||
|
(cond
|
||
|
((equal 0 n) (first listA))
|
||
|
(t (nth (- n 1) (rest listA)))))
|