newLISP Fan Club

Forum => newLISP in the real world => Topic started by: Kazimir Majorinc on September 30, 2009, 09:44:01 AM

Title: (difference '(nil a) (list true nil))
Post by: Kazimir Majorinc on September 30, 2009, 09:44:01 AM
It appears to be error:


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

(println (difference '(nil a) (list true nil))) ;=>(nil a)[/list]
Title:
Post by: Lutz on September 30, 2009, 11:29:47 AM
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)