syntax - What's the difference between eq, eql, equal and equalp, in Common Lisp? -


what's difference between eq, eql, equal , equalp, in common lisp? understand of them check types, of them check across types that, which? when 1 better use others?

from common lisp: equality predicates

(eq x y) true if , if x , y same identical object.

the eql predicate true if arguments eq, or if numbers of same type same value, or if character objects represent same character.

the equal predicate true if arguments structurally similar (isomorphic) objects. rough rule of thumb 2 objects equal if , if printed representations same.

two objects equalp if equal; if characters , satisfy char-equal, ignores alphabetic case , other attributes of characters; if numbers , have same numerical value, if of different types; or if have components equalp.

here examples same page linked above:

(eq 'a 'b) false.  (eq 'a 'a) true.  (eq 3 3) might true or false, depending on implementation.  (eq 3 3.0) false.  (eq 3.0 3.0) might true or false, depending on implementation.  (eq #c(3 -4) #c(3 -4))    might true or false, depending on implementation.  (eq #c(3 -4.0) #c(3 -4)) false.  (eq (cons 'a 'b) (cons 'a 'c)) false.  (eq (cons 'a 'b) (cons 'a 'b)) false.  (eq '(a . b) '(a . b)) might true or false.  (progn (setq x (cons 'a 'b)) (eq x x)) true.  (progn (setq x '(a . b)) (eq x x)) true.  (eq #\a #\a) might true or false, depending on implementation.  (eq "foo" "foo") might true or false.  (eq "foo" (copy-seq "foo")) false.  (eq "foo" "foo") false.   (eql 'a 'b) false.  (eql 'a 'a) true.  (eql 3 3) true.  (eql 3 3.0) false.  (eql 3.0 3.0) true.  (eql #c(3 -4) #c(3 -4)) true.  (eql #c(3 -4.0) #c(3 -4)) false.  (eql (cons 'a 'b) (cons 'a 'c)) false.  (eql (cons 'a 'b) (cons 'a 'b)) false.  (eql '(a . b) '(a . b)) might true or false.  (progn (setq x (cons 'a 'b)) (eql x x)) true.  (progn (setq x '(a . b)) (eql x x)) true.  (eql #\a #\a) true.  (eql "foo" "foo") might true or false.  (eql "foo" (copy-seq "foo")) false.  (eql "foo" "foo") false.   (equal 'a 'b) false.  (equal 'a 'a) true.  (equal 3 3) true.  (equal 3 3.0) false.  (equal 3.0 3.0) true.  (equal #c(3 -4) #c(3 -4)) true.  (equal #c(3 -4.0) #c(3 -4)) false.  (equal (cons 'a 'b) (cons 'a 'c)) false.  (equal (cons 'a 'b) (cons 'a 'b)) true.  (equal '(a . b) '(a . b)) true.  (progn (setq x (cons 'a 'b)) (equal x x)) true.  (progn (setq x '(a . b)) (equal x x)) true.  (equal #\a #\a) true.  (equal "foo" "foo") true.  (equal "foo" (copy-seq "foo")) true.  (equal "foo" "foo") false.   (equalp 'a 'b) false.  (equalp 'a 'a) true.  (equalp 3 3) true.  (equalp 3 3.0) true.  (equalp 3.0 3.0) true.  (equalp #c(3 -4) #c(3 -4)) true.  (equalp #c(3 -4.0) #c(3 -4)) true.  (equalp (cons 'a 'b) (cons 'a 'c)) false.  (equalp (cons 'a 'b) (cons 'a 'b)) true.  (equalp '(a . b) '(a . b)) true.  (progn (setq x (cons 'a 'b)) (equalp x x)) true.  (progn (setq x '(a . b)) (equalp x x)) true.  (equalp #\a #\a) true.  (equalp "foo" "foo") true.  (equalp "foo" (copy-seq "foo")) true.  (equalp "foo" "foo") true. 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -