Page Numbers: Yes X: 306 Y: 1.0" First Page: 57
Margins: Top: 1.0" Bottom: 1.3"
Heading:
STANDARD PROCEDURE GUIDE3-LISP REFERENCE MANUALJanuary 25, 1983
————————————————————————————————————————————
9.f. IDENTITY
————————————————————————————————————————————
(= E1 E2 ... EK)
When K is two, true if E1 and E2 designate the same structure; false otherwise. However, an error will be detected if both E1 and E2 designate functions. When both E1 and E2 designate sequences, corrseponding elements are (using =) from left to right until it can be established that the two sequences differ, or until an error is detected. Consequently, (= E1 E2) may fail to terminate when E1 and E2 designate infinite sequences (or sequences containing infinite sequences). Note that although equality is defined over closures, it is too fine grained to be used for function identity. When K is greater than 2, EI will not be compared to E1 unless E1 through EI-1 have been determined to all designate the same structure.
Properties:Primitive; protected; kernel.
F-Type:[ OBJECTS X OBJECTS X {OBJECTS}* ] TRUTH-VALUES
Examples:(= 3 (+ 1 2))g$T
(= 5 ’5)g$F
(= ’5 ’5)g$T
(= $F $F $F $F)g$T
(= [10 20] [10 20])g$T
(= ’[10 20] ’[10 20])
g$F
(= ’[10 20] [’10 ’20])
g$F
(= CAR CDR)
g{ERROR: = not defined over functions.}
(= CAR 3)
g$F
(= [+ 2] [+ 3])
g{ERROR: = not defined over functions.}
(= [2 +] [3 +])
g$F
(= + 1 +)
g$F
(= + + 1)
g{ERROR: = not defined over functions.}
Semantics:S(E0("=),E,F,C) = l ...
———————————————————
(ISOMORPHIC E1 E2)
True if E1 and E2 designate similar structures; false otherwise. When either E1 or E2 designates an external structure ISOMORPHIC behaves just like =. Otherwise, two internal structures are isomorphic if they are = or have isomorphic corresponding components. ISOMORPHIC may fail to terminate on circular structures.
F-Type:[ OBJECTS X OBJECTS ] TRUTH-VALUES
Examples:(ISOMORPHIC ’5 ’5)g$T
(ISOMORPHIC ’[10 20] ’[10 20])g$T
(ISOMORPHIC ’[10 20] [’10 ’20])
g$F
(ISOMORPHIC ↑CAR ↑CDR)
g$F
(ISOMORPHIC ’(A . B) ’(A . B))
g$T
(ISOMORPHIC ’’[X] ’’[X])
g$T
(ISOMORPHIC ↑(LAMBDA SIMPLE [X] X)
↑(LAMBDA SIMPLE [X] X))
g$T
Semantics:S(E0("ISOMORPHIC),E,F,C) = l ...
————————————————————————————————————————————
9.g. ARITHMETIC OPERATIONS
————————————————————————————————————————————
(+ N1 N2 ... Nk)
(* N1 N2 ... Nk)
Designate, respectively, the sum and product of the numbers designated by N1 through Nk. (+) designates 0; and (*) designates 1.
Properties:Primitive; protected.
F-Type:[ {NUMBERS}* ] NUMBERS
Examples:(* 2 2 2 2)g16
(+ 1 3 5)
g9
(+ 3)
g3
(* 3)
g3
(+)
g0
(*)
g1
(+ ’1 ’2)
g{ERROR: Number expected.}
Semantics:S(E0("+),E,F,C) = l ...
S(E0("*),E,F,C) = l ...
———————————————————
(- N1 N2 ... Nk)
Designates the difference of the numbers designated by N1 through Nk. k must be at least 1. Specifically, (- N) is equivalent to (- 0 N), and (- N1 N2 ... Nk) is equivalent to (- N1 (+ N2 ... Nk)).
Properties:Primitive; protected.
F-Type:[ NUMBER X {NUMBERS}* ] NUMBERS
Examples:(- 100 2)g98
(- 3)
g-3
(- 10 20)
g-10
(- 9 1 3 5)
g0
(- 9 (+ 1 3 5))
g9
(-3)
g{ERROR: Not a function.}
(- 0 $T)
g{ERROR: Number expected.}
Semantics:S(E0("-),E,F,C) = l ...
———————————————————
(/ N1 N2)
Designates the quotient of the numbers designated by N1 and N2. (/ N1 N2) will cause an error if N2 designates zero. Currently, arithmetic is defined only on integers; ultimately we intend to define full rational (or repeating fraction) arithmetic, with no upper limit on numeral size, and no limit on precision.
Properties:Primitive; protected.
F-Type:[ NUMBERS X NUMBERS ] NUMBERS
Examples:(/ 10 3)g3
(/ -10 3)
g-3
(/ 10 -3)
g-3
(/ -10 -3)
g3
(/ 100 0)
g{ERROR: Division by zero.}
Semantics:S(E0("/),E,F,C) = l ...
———————————————————
(REMAINDER N1 N2)
Designates the remainder upon dividing N1 by N2; error if N2 designates zero.
F-Type:[ NUMBER X NUMBERS ] NUMBERS
Examples:(REMAINDER 10 3)g1
(REMAINDER 10 -3)
g1
(REMAINDER -10 -3)
g-1
(REMAINDER -10 -3)
g-1
(REMAINDER 10 0)
g{ERROR: Division by zero.}
Semantics:S(E0("REMAINDER),E,F,C) = l ...
———————————————————
(1+ N)
(1- N)
Designates the number one greater than (or one less than) the number designated by N.
F-Type:[ NUMBERS ] NUMBERS
Examples:(1+ 20)g21
(MAP 1- [2 3 4])
g[1 2 3]
Semantics:S(E0("1+),E,F,C) = l ...
S(E0("1-),E,F,C) = l ...
———————————————————
(< N1 N2 ... Nk)
(<= N1 N2 ... Nk)
(> N1 N2 ... Nk)
(>= N1 N2 ... Nk)
True if and only if the number designated by N1 is less than the number designated by N2, the number designated by N2 is less than the number designated by N3, etc. Similarly for the others, except that the relationship is that of being less than or equal (<=), greater than (>), or greater than or equal (>=). In all cases, k must be at least 2.
Properties:Primitive; protected.
F-Type:[ NUMBERS X NUMBERS X {NUMBERS}* ] TRUTH-VALUES
Examples:(< 2 3)g$T
(>= 5 4 4 2 -7 -1)
g$T
(<= 99 1 ’1)
g{ERROR: Number expected.}
(> 100 1000)
g$F
Semantics:S(E0("<),E,F,C) = l ...
S
(E0("<=),E,F,C) = l ...
S
(E0(">),E,F,C) = l ...
S
(E0(">=),E,F,C) = l ...
———————————————————
(ABS N)
Designates the absolute value of the number designated by N.
F-Type:[ NUMBER ] NUMBERS
Examples:(ABS 100)g100
(ABS -100)
g-100
(ABS 0)
g0
(ABS ’1)
g{ERROR: Number expected.}
Semantics:S(E0("ABS),E,F,C) = l ...
———————————————————
(MIN N1 N2 ... Nk)
(MAX N1 N2 ... Nk)
Designate, respectively, the minimum and maximum of the numbers designated by N1 through Nk (K>𔁇).
F-Type:[ NUMBERS X {NUMBERS}* ] NUMBERS
Examples:(MIN 3 1 4)g1
(MIN 0 1 -7)
g-7
(MAX 4)
g4
Semantics:S(E0("MIN),E,F,C) = l ...
S(E0("MAX),E,F,C) = l ...
———————————————————
(ODD N)
(EVEN N)
True if N designates an odd or even number, respectively.
F-Type:[ NUMBERS ] TRUTH-VALUES
Examples:(ODD 100)g$F
(EVEN 100)
g$T
(ODD -1)
g$T
Semantics:S(E0("ODD),E,F,C) = l ...
S(E0("EVEN),E,F,C) = l ...
———————————————————
(ZERO N)
(NEGATIVE N)
(POSITIVE N)
(NON-NEGATIVE N)
True if the number N designates is equal to, less than, greater than, or greater than or equal to zero, respectively..
F-Type:[ NUMBERS ] TRUTH-VALUES
Examples:(ZERO 1)g$F
(NEGATIVE -1)
g$T
(POSITIVE 0)
g$F
(NON-NEGATIVE 0)
g$T
(POSITIVE -1)
g$F
Semantics:S(E0("ZERO),E,F,C) = l ...
S(E0("NEGATIVE),E,F,C) = l ...
S(E0("POSITIVE),E,F,C) = l ...
S(E0("NON-NEGATIVE),E,F,C) = l ...
———————————————————
(** N1 N2)
Designates the N2-fold product of the number designated by N1 with itself. N2 must designate a non-negative number.
F-Type:[ NUMBERS X NUMBERS ] NUMBERS
Examples:(** 2 10)g1024
(** 10 0)
g1
(** -5 3)
g-125
Semantics:S(E0("**),E,F,C) = l ...
———————————————————
(HASH S N)
Designates a number in the range from 0 to the number designated by N, based on the identity of the internal structure designated by S. (It would be an understatement to say that the current hashing function is woefully inadequate.)
Properties:Primitive; protected.
F-Type:[ STRUCTURES X NUMBERS ] NUMBERS
Examples:(HASH ’A 0)g0
(HASH ↑LAMBDA (** 2 16))
g{Some large random number (probably).}
Semantics:S(E0("HASH),E,F,C) = l ...
———————————————————