3 ms·
Some Lisp: (defun foo (ls) (mapcar (lambda (x) (+ (f x) 2)) ls))) Trim unnecessary parenthesis (map is mapcar, \x -> … is lambda expr): foo ls
by lelf 13y ago
Some Lisp:
(defun foo (ls)
(mapcar (lambda (x) (+ (f x) 2))
ls)))
Trim unnecessary parenthesis (map is mapcar, \x -> … is lambda expr):
foo ls =
map (\x -> ((+) (f x) 2))
ls
With infix syntax
foo ls = map (\x -> f x + 2) ls
And only if you really want it:
foo = map (\x -> f x + 2)
foo = map ((+2) . f)
- anuragramdasan 13y agoThank you. That is some good way to look at it. I think people here assumed that I hated haskell or something. This breakdown actually makes it a lot clear to me. Thanks :)