Page 1 of 1
(difference '(nil a) (list true nil))
Posted: Wed Sep 30, 2009 4:44 pm
by Kazimir Majorinc
It appears to be error:
- (println (difference '(nil a) '(true nil))) ;=>(a)
(println (difference '(nil a) (list true nil))) ;=>(nil a)
Posted: Wed Sep 30, 2009 6:29 pm
by Lutz
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'.
Code: Select all
> (sort '(a nil)) => (a nil)
(sort (list 'a nil)) => (nil a)
and:
Code: Select all
(difference (list nil 'a) (list true nil)) => (a)
(difference (list nil 'a) '(true nil)) => (a)