returning the empty list

Started by Sammo, January 13, 2004, 02:21:11 PM

Previous topic - Next topic

Sammo

shouldn't both return ()?



> (if true '() '())

()



> (if nil '() '())

nil

Lutz

#1
'if' can take multiple condition/action pairs similar o 'cond' but wihtout the parenthesis, so it take the last '() as a condition and evaluates it. As it evluates to logigal nil it returns nil.



I agree that this very un-intuitive,  and will change the behaviour for both 'if' and 'cond', so in the future:



(if nil '() '()) => ()    ; previously nil

and



(cond (nil 1) (nil 2) ('())) => () ; previously nil



Lutz