4 points · by adrusi · 14y ago · 5 comments
For example, here's something like how a Schemer might implement filter (although this seems long to me...am I missing something?):
(defun filter (predicate list)
(if list
(let ((head (car list))
(tail (cdr list)))
(if (funcall predicate head)
(cons head (filter predicate tail))
(filter predicate tail)))
'()))
But realistically, a CLer would probably just use the loop macro: (defun filter (predicate list)
(loop for elem in list
if (funcall predicate elem)
collect elem))
So if you're interested in a non-castrated language that very deliberately tries to be practical (if at times inelegant)...it's worth a look. Pick up the book Land of Lisp if you're in a whimsical mood, or Practical Common Lisp if you're not.So yeah it's worth it!