Page Numbers: Yes X: 306 Y: 1.0" First Page: 49
Margins: Top: 1.0" Bottom: 1.3"
Heading:
STANDARD PROCEDURE GUIDE3-LISP REFERENCE MANUALJanuary 25, 1983
———————————————————
(CONCATENATE R1 R2)
CONCATENATE works by replacing the foot of the rail designated by R1 with the rail designated by R2. More formally, if L1 and L2 are the lengths of the rails designated by R1 and R2, respectively, then (CONCATENATE R1 R2) designates a rail of length L1+L2, whose first L1 elements are the elements of the rail designated by R1, whose next L2’th tail is the rail R2. The rail to which R1 normalises is affected, so CONCATENATE should be used with extreme caution; normally APPEND will do the job..
Properties:Smash.
F-Types:[ RAILS X RAILS ] ← RAILS
Examples:(CONCATENATE ’[A] ’[B C])g’[A B C]
(LET [[X (RCONS)]]
(BLOCK (CONCATENATE X ’[NEW TAIL])
X))g’[NEW TAIL]
(LET [[X ’[1 2 3]]
[Y ’[4 5]]]
(BLOCK (CONCATENATE X Y)
[X Y]))g[’[1 2 3 4 5]
’[4 5]]
Semantics:S(E0("CONCATENATE),E,F,C) = l ...
———————————————————
(APPEND V1 V2)
If L1 and L2 are the respective lengths of the vectors designated by V1 and V2, (APPEND V1 V2) designates the vector of length L1+L2 whose first L1 elements are the elements of V1, and whose remaining L2 elements are those of V2. The vectors designated by each V1 must be of the same type. If the Vi designate sequences, (APPEND V1 V2) returns a rail whose first L1 tails (0 through L1-1) are otherwise inacessible, but whose L1’th tail is the rail to which V2 normalises.
Properties:Cons.
F-Types:[ RAILS X RAILS ] ← RAILS
[ SEQUENCES X SEQUENCES ] ← SEQUENCES
Examples:(APPEND [1 2 3] [4 5 6])g[1 2 3 4 5 6]
(APPEND ’[] ’[A B C])g’[A B C]
(LET [[X ’[M N]]] (APPEND X X))g’[M N M N]
(LETSEQ [[X ’[M N]] [Y (APPEND X X)]]
(= X (TAIL 2 Y)))g$T
(LET [[X [1 2]] [Y [3 4]]]
(BLOCK (APPEND X Y)
X))g[1 2]
(APPEND "Of shoes" " and ships")g"Of shoes and ships"
(APPEND 1 [2 3])g{ERROR: Vector expected.}
Semantics:S(E0("APPEND),E,F,C) = l ...
———————————————————
(APPEND* V1 V2 ... Vk)
APPEND* is a variant of APPEND that accepts multiple argument vectors. More formally, if Li is the length of the vector designated by each Vi, (APPEND V1 V2 ... Vk) designates the vector of length L1+L2+ ... + Lk whose first L1 elements are the elements of the vector designated by V1, and whose next L2 elements are the elements of the vector designated by V2, etc. (K >). The vectors designated by each Vi must be of the same type. If the Vi designate sequences, (APPEND V1 V2 ... Vk) returns a rail whose first L1+L2+ ... +Lk-1 tails (0 through L1+L2+ ... +Lk-1-1) are otherwise inacessible, but whose (L1+L2+ ... +Lk-1)’th tail is the rail to which Vk normalises.
Properties:Cons.
F-Types:[ RAILS X {RAILS}* ] ← RAILS
[ SEQUENCES X {SEQUENCES}* ] ← SEQUENCES
Examples:(APPEND* [1 2 3] [4 5 6] [7 8 9])g[1 2 3 4 5 6 7 8 9]
(APPEND* ’[A B C])g’[A B C]
(LET [[X ’[G O]]] (APPEND* X X X))g’[G O G O G O]
(APPEND* "Mac" "H" "i" "n" "e")g"MacHine"
Semantics:S(E0("APPEND*),E,F,C) = l ...
———————————————————
(REVERSE VEC)
Designates a vector (of the type of the vector designated by VEC) whose elements are the same as the elements of the vector designated by VEC, except in reverse order. If VEC designates a sequence, (REVERSE VEC) returns an otherwise completely inaccessible normal-form designator of the reversed sequence; if VEC designates a rail, (REVERSE VEC) designates an otherwise completely inaccessible rail of the reversed elements, and returns a handle.
Properties:Cons.
F-Types:[ RAILS ] ← RAILS
[ SEQUENCES ] ← SEQUENCES
Examples:(REVERSE [])g[]
(REVERSE [1 2 3])g[3 2 1]
(REVERSE ’[[A B] [C D]])g’[[C D] [A B]]
(LET [[X [10]]] (= X (REVERSE X)))g$T
(LET [[X [10]]]
(= ↑X ↑(REVERSE X)))g$T
(LET [[Y ’[A]]] (= Y (REVERSE Y)))g$F
Semantics:S(E0("REVERSE),E,F,C) = l ...
———————————————————
(REVERSE-IN-PLACE VEC)
Designates the same thing as (REVERSE VEC), but modifies the structural field. Specifically, if VEC designates a rail, (REVERSE-IN-PLACE VEC) causes the elements of that rail to be changed into reverse order. If VEC designates a sequence, then (REVERSE-IN-PLACE VEC) returns the rail to which VEC normalises, except that its elements will have been changed into the reverse order. REVERSE-IN-PLACE should be used with extreme caution.
Properties:Cons. (Not yet implemented.)
F-Types:[ RAILS ] ← RAILS
[ SEQUENCES ] ← SEQUENCES
Examples:(REVERSE-IN-PLACE ’[1 2 3])g’[3 2 1]
(LET [[X ’[A B]]]
(BLOCK (REVERSE-IN-PLACE X)
X))g’[B A]
(LETSEQ [[X [2 3 4]] [Y (PREP 1 X)]]
(BLOCK (REVERSE-IN-PLACE Y)
X))g[3 2 1]
Semantics:S(E0("REVERSE-IN-PLACE),E,F,C) = l ...
———————————————————
————————————————————————————————————————————
9.c. CLOSURES
————————————————————————————————————————————
(CCONS KIND DEF-ENV PATTERN BODY)
Designates an otherwise inaccessible closure of the type designated by KIND (typically either SIMPLE or REFLECT) containing designators of the environment designated by DEF-ENV, the pattern designated by PATTERN, and the body designated by B Note how a level-crossing operation (↑) will typically be used to construct closures; this is because closures are a failure. (CCONS will rarely be used explicitly by a user program.)
Properties:Primitive; protected; kernel; cons.
F-Type:[ ATOMS X RAILS X STRUCTURES X STRUCTURES ] ← CLOSURES
Examples:(CCONS ’X ’[] ’Y ’Z)g’{closure: X [] Y Z}
(CCONS ’SIMPLE ↑GLOBAL ’[X] ’X)g’{closure: simple {global} [X] X}
(↑(CCONS ’SIMPLE ↑GLOBAL ’[X] ’(+ X 1)) 10)g11
Semantics:S(E0("CCONS),E,F,C) = l ...
———————————————————
(PROCEDURE-TYPE CLOSURE)
Designates the atom that is the PROCEDURE-TYPE of the closure designated by CLOSURE.
Properties:Primitive; protected; kernel.
F-Type:[ CLOSURES ] ← ATOMS
Examples:(PROCEDURE-TYPE (CCONS ’X ’[] ’Y ’Z))g’X
(PROCEDURE-TYPE ↑+)g’SIMPLE
(PROCEDURE-TYPE ↑IF)g’REFLECT
(PROCEDURE-TYPE IF)g{ERROR: Closure expected.}
Semantics:S(E0("PROCEDURE-TYPE),E,F,C) = l ...
———————————————————
(ENVIRONMENT-DESIGNATOR CLOSURE)
Designates the rail that is the ENV of the closure designated by CLOSURE. Note that while ENVIRONMENT-DESIGNATOR is semantically flat, closures are confused (they contain environment designators instead of environments). ENVIRONMENT is almost always more appropriate.
Properties:Primitive; protected; kernel.
F-Type:[ CLOSURES ] ← RAILS
Examples:(ENVIRONMENT-DESIGNATOR (CCONS ’X ’[] ’Y ’Z))g’[]
(ENVIRONMENT-DESIGNATOR +)g{ERROR: Closure expected.}
Semantics:S(E0("ENVIRONMENT-DESIGNATOR),E,F,C) = l ...
———————————————————
(ENVIRONMENT CLOSURE)
Designates the environment in the closure designated by CLOSURE.
Properties:Protected; kernel.
F-Type:[ CLOSURES ] ← SEQUENCES
Examples:(ENVIRONMENT (CCONS ’X ’[] ’Y ’Z))g[]
(ENVIRONMENT +)g{ERROR: Closure expected.}
Semantics:S(E0("ENVIRONMENT),E,F,C) = l ...
———————————————————
(PATTERN CLOSURE)
Designates the internal structure that is the PATTERN of the closure designated by CLOSURE.
Properties:Primitive; protected; kernel.
F-Type:[ CLOSURES ] ← STRUCTURES
Examples:(PATTERN (CCONS ’X ’[] ’Y ’Z))g’Y
(PATTERN ↑(LAMBDA SIMPLE [A B] (PCONS B A)))g’[A B]
(PATTERN +)g{ERROR: Closure expected.}
Semantics:S(E0("PATTERN),E,F,C) = l ...
———————————————————
(BODY CLOSURE)
Designates the internal structure that is the BODY of the closure designated by CLOSURE.
Properties:Primitive; protected; kernel.
F-Type:[ CLOSURES ] ← STRUCTURES
Examples:(BODY (CCONS ’X ’[] ’Y ’Z))g’Z
(BODY ↑(LAMBDA SIMPLE [A B] (PCONS B A)))g’(PCONS B A)
(BODY +)g{ERROR: Closure expected.}
Semantics:S(E0("BODY),E,F,C) = l ...
———————————————————
(SIMPLE DEF-ENV PATTERN BODY)
(REFLECT DEF-ENV PATTERN BODY)
Designates a function; returns an otherwise inaccessible closure of procedure type SIMPLE or REFLECT, respectively, with environment DEF-ENV, pattern PATTERN, and body BODY. Note that SIMPLE and REFLECT are designed to be used with LAMBDA and are not semantically flat.
Properties:Protected; kernel; cons.
F-Type:[ RAILS X STRUCTURES X STRUCTURES ] ← CLOSURES
Examples:(SIMPLE ’[] ’Y ’Z)g{closure: simple [] Y Z}
(REFLECT ↑GLOBAL ’[X] ’X)g{closure: reflect {global} [X] X}
((SIMPLE ↑GLOBAL ’[X] ’(+ X 1)) 10)g11
Semantics:S(E0("SIMPLE),E,F,C) = l ...
S(E0("REFLECT),E,F,C) = l ...
———————————————————
(REFLECTIVE CLOSURE)
True just in case the PROCEDURE-TYPE of the closure designated by CLOSURE is the atom REFLECT.
Properties:Protected; kernel.
F-Type:[ CLOSURES ] ← TRUTH-VALUES
Examples:(REFLECTIVE ↑+)g$F
(REFLECTIVE ↑IF)g$T
(REFLECTIVE ↑LET)g$T
(REFLECTIVE (CCONS ’X ’[] ’Y ’Z))g$F
Semantics:S(E0("REFLECTIVE),E,F,C) = l ...
———————————————————
(DE-REFLECT CLOSURE)
Designates an otherwise inaccessible closure whose PROCEDURE-TYPE is the atom SIMPLE and whose other components are the same as those of the closure designated by CLOSURE.
Properties:Protected; kernel.
F-Type:[ CLOSURES ] ← CLOSURES
Examples:(DE-REFLECT (CCONS ’X ’[] ’Y ’Z))g{closure: simple [] Y Z}
Semantics:S(E0("DE-REFLECT),E,F,C) = l ...
———————————————————
(REFLECTIFY FUN)
Designates a function; returns an otherwise inaccessible closure whose PROCEDURE-TYPE is the atom REFLECT and whose other components are the same as those of the closure to which FUN normalises. For example, BLOCK is defined in section 8 to be (REFLECTIFY BLOCK-HELPER).
Properties:Protected; kernel; cons.
F-Type:[ FUNCTIONS ] ← FUNCTIONS
Examples:(REFLECTIFY (CCONS ’X ’[] ’Y ’Z))g{closure: reflect [] Y Z}
Semantics:S(E0("REFLECTIFY),E,F,C) = l ...
———————————————————
————————————————————————————————————————————
9.d. ATOMS
————————————————————————————————————————————
(ACONS)
Returns the handle of an otherwise inaccessible atom.
Properties:Primitive; protected; cons.
F-Type:[ ] ← ATOMS
Examples:(ACONS)g{atom}
(= (ACONS) (ACONS))g$F
Semantics:S(E0("ACONS),E,F,C) = l ...
———————————————————
————————————————————————————————————————————
9.e. TYPING
————————————————————————————————————————————
(TYPE A)
Designates the atom associated with the type of the object designated by A (chosen from the standard 15).
Properties:Primitive; protected; kernel.
F-Type:[ OBJECTS ] ← ATOMS
Examples:(TYPE 3)g’NUMBER
(TYPE ’3)g’NUMERAL
(TYPE $T)g’TRUTH-VALUE
(TYPE ’$F)g’BOOLEAN
(TYPE #A)g’CHARACTER
(TYPE ’#4)g’CHARAT
(TYPE [1 2 3])g’SEQUENCE
(TYPE ’[1 2 3])g’RAIL
(TYPE +)g’FUNCTION
(TYPE ↑+)g’CLOSURE
(TYPE PRIMARY-STREAM)g’STREAM
(TYPE ↑PRIMARY-STREAM)g’STREAMER
(TYPE ’(= 2 3))g’PAIR
(TYPE ’A)g’ATOM
(TYPE ’’3)g’HANDLE
(TYPE ’’’’’’’?)g’HANDLE
Semantics:S(E0("TYPE),E,F,C) = l ...
———————————————————
(ATOM E)
(BOOLEAN E)
(CHARACTER E)
(CHARAT E)
(CLOSURE E)
(FUNCTION E)
(HANDLE E)
(NUMBER E)
(NUMERAL E)
(PAIR E)
(RAIL E)
(SEQUENCE E)
(STREAM E)
(STREAMER E)
(TRUTH-VALUE E)
Each of the fifteen type predicates are true of elements of each of fifteen semantic categories, and false of all others. Specifically, (ATOM E) is true (designates Truth) iff E designates an atom (and similarly for the others).
Properties:Protected; kernel (ATOM, PAIR, RAIL, HANDLE only ) .
F-Type:[ OBJECTS ] ← TRUTH-VALUES
Examples:(ATOM ’A)g$T
(PAIR ’(1ST ’[A B]))g$T
(FUNCTION +)g$T
(CLOSURE ’+)g$F
———————————————————
(VECTOR E)
True if and only if E designates either a rail or a sequence; false otherwise.
Properties:Protected.
F-Type:[ OBJECTS ] ← TRUTH-VALUES
Examples:(VECTOR [1 2 3])g$T
(VECTOR ’[A B])g$T
(VECTOR ’(1 2 3))g$F
(VECTOR "String")g$T
Semantics:S(E0("VECTOR),E,F,C) = l ...
———————————————————
(INTERNAL E)
(EXTERNAL E)
(INTERNAL E) is true if and only if E designates an internal structure such as a numeral or a rail; false otherwise. Similarly, (EXTERNAL E) is true just in case E designates an external structure (i.e., an abstraction) such as a number or a sequence; false otherwise.
Properties:Protected.
F-Type:[ OBJECTS ] ← TRUTH-VALUES
Examples:(EXTERNAL 123)g$T
(INTERNAL 123)g$F
(EXTERNAL +)g$T
(INTERNAL ’+)g$T
(INTERNAL ↑+)g$T
Semantics:S(E0("INTERNAL),E,F,C) = l ...
S(E0("EXTERNAL),E,F,C) = l ...
———————————————————
(CHARACTER-STRING E)
True if an only if E designates a sequence of one or more characters; false othewise.
Properties:Nothing special..
F-Type:[ OBJECTS ] ← TRUTH-VALUES
Examples:(CHARACTER-STRING "Hello")g$T
(CHARACTER-STRING [#A #B #C])g$T
(CHARACTER-STRING #X)g$F
(CHARACTER-STRING "")g$F
(CHARACTER-STRING ’[1 2 3])g$F
(CHARACTER-STRING (PREP 1 "2"))g$F
Semantics:S(E0("CHARACTER-STRING),E,F,C) = l ...
———————————————————