Chad said:
Point C really throws me. I guess my Ruby bias is showing.
I think you misunderstood the sentence. In Lisps nil is the empty list
(= the last element of a recursive list), and in ordinary Lisps it's THE
false constant at the same time. In Scheme the empty list is a true
value like Ruby's empty array, but there are also literal constants #t
for true and #f for false, while there is only a symbolic T constant for
true in ordinary Lisps.
So if you would write
(defun sum (l)
(if (not l)
0
(+ (car l) (sum (cdr l)))))
in Common Lisp, you would have to write
(define (sum l)
(if (null? l)
0
(+ (car l) (sum (cdr l)))))
in Scheme. Of course you could shorten the Common Lisp version to:
(defun sum (l)
(if l
(+ (car l) (sum (cdr l)))
0))
But in Common Lisp it's more common (ha!) to use the loop construct
(loop for i from 1 to 3 sum i)
because it's not required for Common Lisps to have tail call optimization.
In general Ruby's kind of nil (as an undefined "value") doesn't come up
very much in Scheme (or the other Lisps), because all variables have to
be explicitly bound to a value for a scope if you want to access them.