Re:List of IPython Notebooks by Peter Norvig
by gjm11 on Monday August 01, 2016 @04:39AM
(#12200930)
In Lisp too -- arguably easier than in most languages. To add 10+9+8 in Lisp you write (+ 10 9 8), a single 3-ary call to +. In, say, C you write 10+9+8 and the parser turns that into two 2-ary additions.
(Of course, in either language you end up with two 2-operand ADD instructions in the object code. Nothing has hardware for arbitrary n-ary adds!)
Re:List of IPython Notebooks by Peter Norvig
by zitterbewegung on Sunday July 31, 2016 @10:08PM
(#12199859)
Think about when you evaluate the expression (10+9+8). You will either add 10+9 or 9+8 first and add 19 to 8 or 17 to 8. (10+9+8) is ambiguous because it can be parsed both ways.
Re:List of IPython Notebooks by Peter Norvig
by projectramo on Sunday July 31, 2016 @08:47PM
(#12199638)
When something like this happens: when the author of one of my favorite computer science text books releases an interactive notebook my main sensation is one of envy.
I really envy all the students who get to study Norvig like this.
Also, you'll probably have access to better health care.
>because there are 2 ways to make 27 with the numbers (10, 9, 8), namely, ((10+9)+8) and (10+(9+8))
why not also (10+9+8)?
(Of course, in either language you end up with two 2-operand ADD instructions in the object code. Nothing has hardware for arbitrary n-ary adds!)
If you don't write it so explicitly, a compiler will do it for you anyway.
http://nbviewer.jupyter.org/url/norvig.com/ipython/Cheryl.ip...
Such elegant and readable translation from English to logic to code.
I really envy all the students who get to study Norvig like this.
Also, you'll probably have access to better health care.