Search found 2 matches

by eric-and-jane-smith
Sat Feb 21, 2009 1:36 am
Forum: Common Lisp
Topic: Discussion on possible lambda syntax: Good or Evil?
Replies: 17
Views: 31731

Re: Discussion on possible lambda syntax: Good or Evil?

; cf = Compose function with optional currying. ; Example usage: ; (mapcar (cf (* 2) (+ 10 20) -) '(1 2 3)) ; ==> (-32 -34 -36) ; Each argument to cf gets converted to a function, ; and the functions are applied in left to right ; order. E.g. (cf f1 f2 f3) is equivalent to ; (lambda (x) (f3 (f2 (f1...
by eric-and-jane-smith
Sat Feb 21, 2009 1:13 am
Forum: Common Lisp
Topic: A procedure to extract atoms from a list
Replies: 11
Views: 23309

Re: A procedure to extract atoms from a list

(defun atoms (tree) (when tree (if (atom tree) (list tree) (nconc (atoms (car tree)) (atoms (cdr tree)))))) (atoms '(a b (c d) (e f (c d b)))) ==> (A B C D E F C D B) (defun extract-atoms (tree) (remove-duplicates (atoms tree))) (extract-atoms '(a b (c d) (e f (c d b)))) ==> (A E F C D B)