Page Numbers: Yes X: 306 Y: 1.0" First Page: 45
Margins: Top: 1.0" Bottom: 1.3"
Heading:
STANDARD PROCEDURE GUIDE3-LISP REFERENCE MANUALJanuary 25, 1983
———————————————————
(LENGTH VEC)
Designates the numeric length of the rail or sequence designated by VEC; returns the numeral for that number providing it is finite (LENGTH of an infinite vector will never return).
Properties:Primitive; protected.
F-Type:[ {RAILS U SEQUENCES} ] NUMBERS
Examples:(LENGTH ’[A B C])g3
(LENGTH (SCONS))g0
(LENGTH "Five")
g4
(LENGTH 3)g{ERROR: Vector expected.}
Semantics:S(E0("LENGTH),E,F,C) = l ...
———————————————————
(NTH N VEC)
Designates the N’th element of the rail or sequence designated by VEC. Vector elements are numbered starting at 1, not 0; therefore N may range from 1 to the length of the designation of VEC. If VEC designates a sequence, then (NTH N VEC) will return the N’th element of the rail to which VEC normalises.
Properties:Primitive; protected; kernel.
F-Types:[ NUMBERS X RAILS ] STRUCTURES
[ NUMBERS X SEQUENCES ] OBJECTS
Examples:(NTH 1 [(+ 5 5) 20 30])g10
(NTH 2 [’10 ’20 ’30])g’20
(NTH 3 ’[10 20 30])g’30
(NTH 2 [10])g{ERROR: Index too large.}
(NTH ’2 [10 20 30])g{ERROR: Number expected.}
(NTH 1 10)g{ERROR: Vector expected.}
Semantics:S(E0("NTH),E,F,C) = l ...
———————————————————
(TAIL N VEC)
Designates the N’th tail of the rail or sequence designated by VEC (where N may range from 0 to the length of VEC). In general, the I’th tail of a vector of length K is that vector consisting of the (I+1)th through Kth element; thus the zeroeth tail of A is identically A. If (TAIL N VEC) designates a sequence, it will return the N’th tail of the rail to which VEC normalises.
Properties:Primitive; protected; kernel.
F-Types:[ NUMBERS X RAILS ] RAILS
[ NUMBERS X SEQUENCES ] SEQUENCES
Examples:(TAIL 2 [10 20 30 40])g[30 40]
(TAIL 1 (CDR ’(RCONS ’A ’B ’C)))g’[’B ’C]
(LET [[X ’[A B]]] (= X (TAIL 0 X)))g$T
(LETSEQ [[X [2 3]]
[Y (PREP 1 X)]]
(= ↑X ↑(TAIL 1 Y)))
g$T
(TAIL 1 [1])g[]
(TAIL 4 "Kangaroo")g"aroo"
(TAIL 3 [1 2])g{ERROR: Index too large.}
(TAIL $F [1 2])g{ERROR: Number expected.}
(TAIL 1 #C)g{ERROR: Vector expected.}
Semantics:S(E0("TAIL),E,F,C) = l ...
———————————————————
(EMPTY VEC)
True just in case VEC designates an empty rail or sequence; false in case VEC designates a non-empty rail or sequence; undefined otherwise. Note that (EMPTY VEC) will return $F even if VEC designates an infinite vector (in contrast with LENGTH).
Properties:Primitive; protected; kernel.
F-Type:[ {RAILS U SEQUENCES} ] TRUTH-VALUES
Examples:(EMPTY [])g$T
(EMPTY ’[A B C])
g$F
(EMPTY (SCONS))g$T
(EMPTY (RCONS))g$T
(LET [[X (RCONS ’1)]]
(BLOCK (REPLACE (TAIL 1 X) X)
(EMPTY X)))
g$F
(EMPTY ’(A . B))g{ERROR: Vector expected.}
Semantics:S(E0("EMPTY),E,F,C) = l ...
———————————————————
(UNIT VEC)
(DOUBLE VEC)
True just in case the vector designated by VEC is of length 1 or 2, respectively. Note that each of these forms will return $F even if VEC designates an infinite vector (i.e., they are defined in terms of EMPTY, not LENGTH).
Properties:Protected; kernel.
F-Type:[ {RAILS U SEQUENCES} ] TRUTH-VALUES
Examples:(UNIT ’[A])g$T
(DOUBLE (REST [10 20 30]))
g$T
(DOUBLE "Two"
g$F
(UNIT 1)
g{ERROR: Vector expected.}
Semantics:S(E0("UNIT),E,F,C) = l ...
S(E0("DOUBLE),E,F,C) = l ...
———————————————————
(FOOT VEC)
Designates the empty vector that is the last tail of the vector designated by VEC. If VEC designates a sequence; (FOOT VEC) will return the last tail of the rail to which VEC normalises. FOOT is primarily useful in the (destructive) extending of vectors (see the definition of CONCATENATE in section 8.e, for example).
Properties:Nothing special.
F-Types:[ RAILS ] RAILS
[ SEQUENCES ]
SEQUENCES
Examples:(FOOT [1 2 3])g[]
(= (FOOT [1 2 3]) [])
g$T
(= (FOOT ’[1 2 3]) ’[])g$F
(LET [[X (SCONS 10 20)]]
(BLOCK (REPLACE (FOOT ↑X) ’[30 40])
X))
g[10 20 30 40]
Semantics:S(E0("FOOT),E,F,C) = l ...
———————————————————
(REST VEC)
Designates the first tail of the vector designated by VEC. In case (REST VEC) designates a sequence, it returns the first tail of the vector to which VEC normalises. REST plays the role in 3-LISP that CDR plays in standard LISPs when used on lists signifying enumerations.
Properties:Protected; kernel.
F-Types:[ RAILS ] RAILS
[ SEQUENCES ] SEQUENCES
Examples:(REST [1 2 3])g[2 3]
Semantics:S(E0("REST),E,F,C) = l ...
———————————————————
(1ST VEC)
(2ND
VEC)
(3RD
VEC)
(4TH
VEC)
(5TH
VEC)
(6TH
VEC)
These forms designate, respectively, the first, second, third, fourth, fifth, and sixth elements of the vector designated by VEC. In case VEC designates a sequence, each returns the Kth element of the rail to which VEC normalises (1 < K <6). Defined to be (NTH 1 VEC), (NTH 2 VEC), etc.
Properties:Protected; kernel (1ST and 2ND only).
F-Type:[ SEQUENCES ] OBJECTS
[ RAILS ]
STRUCTURES
Examples:(3RD [10 20 30 40])g30
(1ST (PREP ’A ’[B C]))
g’A
(2ND [1])
g{ERROR: Index too large.}
Semantics:S(E0("1ST),E,F,C) = l ...
———————————————————
(MEMBER E VEC)
True (designates Truth) just in case the object designated by E is an element of the vector designated by VEC. If (MEMBER E VEC) is true, it is guaranteed to return; if not, it will terminate only if the vector designated by VEC is finite. Note: since MEMBER is defined in terms of =, it can’t be used over sequences of functions.
Properties:Protected; kernel.
F-Type:[ OBJECTS X {RAILS U SEQUENCES} ] TRUTH-VALUES
Examples:(MEMBER 1 [2 3 4])g$F
(MEMBER 3 [1 1 2 (+ 1 2)])
g$T
(MEMBER ’2 ’[1 2 3])
g$T
(MEMBER 2 ’[1 2 3])
g$F
(MEMBER 2 [’1 ’2 ’3])
g$F
(MEMBER ’[] ’[[A] [] [B]])
g$F
(MEMBER [] [[1] [] [2]])
g$T
(MEMBER 1 2)
g{ERROR: Vector expected.}
(MEMBER * [+ - * /])
g{ERROR: = not defined over functions.}
Semantics:S(E0("MEMBER),E,F,C) = l ...
———————————————————
(VECTOR-CONSTRUCTOR TEMPLATE)
Designates the RCONS or SCONS function, depending on whether TEMPLATE designates an internal structure or external object, respectively. Returns the primitive RCONS or SCONS closure, as appropriate. VECTOR-CONSTRUCTOR is primarily useful in the terminating clause of a recursive defintion defined over general vectors (see the definition of MAP in section 8.e, for example).
Properties:Protected; kernel.
F-Type:[ OBJECTS ] FUNCTIONS
Examples:(VECTOR-CONSTRUCTOR ’[])g{Simple RCONS closure}
((VECTOR-CONSTRUCTOR ’[]))
g’[]
(VECTOR-CONSTRUCTOR 100)
g{Simple SCONS closure}
((VECTOR-CONSTRUCTOR 100))
g[]
(VECTOR-CONSTRUCTOR ↑↑1)
g’[]
Semantics:S(E0("VECTOR-CONSTRUCTOR),E,F,C) = l ...
———————————————————
(MAP FUN V1 V2 ... Vk)
Designates the vector obtained by applying the function designated by FUN (of arity k) to the elements of the vectors designated by V1 through Vk. K should be >𔁆; the vectors V1 through Vk should be of equal length. In the case where the Vi designate sequences, returns an otherwise completely inaccessible rail (whose length is the length of each of the Vi) designating this sequence of values.
Properties:Protected; kernel; cons.
F-Type:[ FUNCTIONS X {SEQUENCES}* ] SEQUENCES
[ FUNCTIONS
X {RAILS}* ] RAILS
Examples:(MAP 1+ [2 3 4])g[3 4 5]
(MAP * [1 2 3] [1 2 3])
g[1 4 9]
(MAP EF [$T $F] [1 2] [3 4])
g[1 4]
(MAP CAR [])
g[]
(MAP 1+ [1 2 3] [4 5 6])
g{ERROR: Too many arguments.}
(MAP 1 [1 2 3])
g{ERROR: Not a function.}
(MAP 1+ 100)
g{ERROR: Vector expected.}
Semantics:S(E0("MAP),E,F,C) = l ...
———————————————————
(COPY-VECTOR VEC)
If VEC designates a rail, (COPY-VECTOR VEC) designates an otherwise completely inaccessible rail whose elements are the elements of the rail designated by VEC. If VEC designates a sequence, (COPY-VECTOR VEC) designates the same sequence as VEC, but returns an otherwise completely inaccessible designator (rail) of it. Note that when VEC designates a sequence, (SCONS . VEC) could be used to achieve the same effect.
Properties:Cons.
F-Types:[ RAILS ] RAILS
[ SEQUENCES ] SEQUENCES
Examples:(COPY-VECTOR ’[A B C])g’[A B C]
(COPY-VECTOR [])
g[]
(LET [[X ’[$T]]] (= X (COPY-VECTOR X)))
g$F
(LET [[Y [1 2 3]]]
[(= Y (COPY-VECTOR Y))
(= ↑Y ↑(COPY-VECTOR Y))])
g[$T $F]
Semantics:S(E0("COPY),E,F,C) = l ...