17.05.2015 Views

zl:1 - FTP

zl:1 - FTP

zl:1 - FTP

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>zl</strong>:equal<br />

202<br />

(setq a 'a) =:> A<br />

(setq b a) =:> A<br />

(equal a b) =:> T<br />

I<br />

<strong>zl</strong>:equal X Y Function<br />

The <strong>zl</strong>:equal predicate returns t if its arguments are similar (isomorphic)<br />

objects. See the function eq, page 198. Two numbers are <strong>zl</strong>:equal if they<br />

have the same value and type (for example, a flonum is never <strong>zl</strong>:equal to<br />

an integer, even if = is true of them). For conses, <strong>zl</strong>:equal is defined<br />

recursively as the two cars being <strong>zl</strong>:equal and the two cdrs being equal.<br />

Two strings are <strong>zl</strong>:equal If they have the same length, and the characters<br />

composing them are the same. See the function string-equal, page 525.<br />

Alphabetic case is ignored. All other objects are <strong>zl</strong>:equal if and only if<br />

they are eq. Thus <strong>zl</strong>:equal could have been defined by:<br />

(defun equal (x y)<br />

(cond «eq x y) t)<br />

«neq (typep x) (typep y» nil)<br />

«numberp x) (= x y»<br />

«stringp x) (string-equal x y»<br />

«listp x) (and (equal (car x) (car y»<br />

(equal (cdr x) (cdr y»»»<br />

As a consequence of the above definition, it can be seen that <strong>zl</strong>:equal may<br />

compute forever when applied to looped list structure. In addition, eq always<br />

implies <strong>zl</strong>:equal; that is, if (eq a b) then (<strong>zl</strong>:equal a b). An intuitive<br />

definition of <strong>zl</strong>:equal (which is not quite correct) is that two objects are<br />

<strong>zl</strong>:equal if they look the same when printed out. For example:<br />

(setq a '(1 2 3»<br />

(setq b '(1 2 3»<br />

(eq a b) =:> nil<br />

(equal a b) => t<br />

(equal "Faa" "faa") =:> t<br />

si:equal-hash X Function<br />

si:equal-hash computes a hash code of an object, and returns it as an integer.<br />

A property of si:equal-hash is that (equal X y) always implies<br />

(= (si:equal-hash x) (si:equal-hash y». The number returned by<br />

si:equal-hash is always a nonnegative integer, possibly a large one.<br />

si:equal-hash tries to compute its hash code in such a way that common<br />

permutations of an object, such as interchanging two elements of a list or<br />

changing one character in a string, always changes the hash code.<br />

si:equal-hash uses %pointer to define the hash key for data types such as

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!