3 ms·
Lisp code is almost always written on multiple lines, with an editor that automatically indents everything. Code in a more familiar language (C?) would also loo
by silentbicycle 17y ago
Lisp code is almost always written on multiple lines, with an editor that automatically indents everything. Code in a more familiar language (C?) would also look incomprehensible if ten lines were all smushed together on one.
I let Emacs indent that, and it came out like so:
(let ((prod (apply #'* probs)))
(/ prod
(+ prod (apply #'*
(mapcar #'(lambda (x)
(- 1 x))
probs)))))
You still have to learn the idioms (it's a different language!), but it's not just a jumble of parenthesis.
Prefix notation takes some getting used to for arithmetic, but that's neither here nor there. You probably have a bundle of idiosyncratic operator precedence rules memorized (quick, does 3*4+5 equal 27 or 17?), and Lisp doesn't use those, preferring to consistently use parenthetical nesting for everything.
See also: http://img264.imageshack.us/img264/1397/lispnd7.png http://img264.imageshack.us/img264/1397/lispnd7.png