From: Kevin R. <kp...@ma...> - 2009-10-15 01:21:16
|
On Oct 14, 2009, at 20:38, Carlos Konstanski wrote: > SVBRONZE> (let ((roles '(roles_dealer))) > (reduce #'(lambda (&optional x y) > (cond ((and x y) (format nil "~a = true OR > ~a = true" x y)) > ((and x (not y)) (format nil "~a = > true" x)) > (t ""))) > (mapcar #'(lambda (role) > (string-downcase (symbol-name role))) > roles))) > "roles_dealer" This is an improper use of REDUCE even if the behavior with one argument were what you wanted. If you give it more than two arguments, say (a b c), you will get the result: a = true OR b = true = true OR c = true Instead, use the :key option to REDUCE or move the addition of "~a = true" into the MAPCAR. If you only wanted this to work for 0, 1, or 2 arguments, then replacing REDUCE with APPLY will make the above code work. Also, STRING-DOWNCASE takes a string designator, so the use of SYMBOL- NAME is unnecessary. -- Kevin Reid <http://switchb.org/kpreid/> |