- (println (difference '(nil a) '(true nil))) ;=>(a)
(println (difference '(nil a) (list true nil))) ;=>(nil a)
(difference '(nil a) (list true nil))
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
(difference '(nil a) (list true nil))
It appears to be error:
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'.
and:
Code: Select all
> (sort '(a nil)) => (a nil)
(sort (list 'a nil)) => (nil a)
Code: Select all
(difference (list nil 'a) (list true nil)) => (a)
(difference (list nil 'a) '(true nil)) => (a)