(difference '(nil a) (list true nil))

Started by Kazimir Majorinc, September 30, 2009, 09:44:01 AM

Previous topic - Next topic

Kazimir Majorinc

It appears to be error:


  • (
println (difference '(nil a) '(true nil)))     ;=>(a)

(println (difference '(nil a) (list true nil))) ;=>(nil a)[/list]
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.

Lutz

#1
This turns out to be a bug in the 'sort' function involved in 'difference'. What happens here is that the symbol 'nil' gets compared with the symbol 'a', then two symbols get compared by their names, but the symbol 'nil' should also be taken as the boolean value 'nil' and sort before the symbol 'a'.


> (sort '(a nil)) => (a nil)
(sort (list 'a nil)) => (nil a)


and:


(difference (list nil 'a) (list true nil)) => (a)
(difference (list nil 'a) '(true nil)) => (a)