5 ms·
Lisp Idioms
- araxima 15y agoIf you happen to know the sequence is a list then might as well (apply #'min '(1 2 3 4 5)) instead of (reduce #'min '(1 2 3 4 5)). I'm sure the author is aware of that, but a reader might get the impression that #'min can only take two arguments.
- sedachv 15y agoApply has the problem in that Common Lisp allows compilers to restrict the number of arguments passed to a function to a small value (specified by call-arguments-limit: http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/convar_call-a_uments-limit.html http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec...).
- deleted 15y ago[deleted]
- technomancy 15y agoMight be useful to mention that these are mostly specific to CL.
- aidenn0 15y agoHis first accumulate misses what is to me the most obvious way: (defun accumulate-f (n) (let* ((end (list (next))) (n (1- n)) (start end)) (dotimes (_ n start) (rplacd end (cons (next) nil)) (setq end (cdr end)))))
- zachbeane 15y agoGene Michael Stover wrote about Common Lisp as someone who hardly ever looked at anyone else's idiomatic use of the language. I was pretty bummed that he got published in Dr. Dobbs with some pretty awful CL code.