1 ( = Type predicates = )
3 :noname ( args -- boolobj )
4 2dup 1 ensure-arg-count
6 car nil objeq? boolean-type
9 :noname ( args -- boolobj )
10 2dup 1 ensure-arg-count
12 car boolean-type istype? -rot 2drop boolean-type
13 ; make-primitive boolean?
15 :noname ( args -- boolobj )
16 2dup 1 ensure-arg-count
18 car symbol-type istype? -rot 2drop boolean-type
19 ; make-primitive symbol?
21 :noname ( args -- boolobj )
22 2dup 1 ensure-arg-count
24 car fixnum-type istype? -rot 2drop boolean-type
25 ; make-primitive integer?
27 :noname ( args -- boolobj )
28 2dup 1 ensure-arg-count
30 car character-type istype? -rot 2drop boolean-type
31 ; make-primitive char?
33 :noname ( args -- boolobj )
34 2dup 1 ensure-arg-count
36 car string-type istype? -rot 2drop boolean-type
37 ; make-primitive string?
39 :noname ( args -- boolobj )
40 2dup 1 ensure-arg-count
42 car pair-type istype? -rot 2drop boolean-type
43 ; make-primitive pair?
45 :noname ( args -- boolobj )
46 2dup 1 ensure-arg-count
48 car primitive-type istype? -rot 2drop boolean-type
49 ; make-primitive procedure?
51 ( = Type conversions = )
53 :noname ( args -- fixnum )
54 2dup 1 ensure-arg-count
55 car character-type ensure-arg-type
58 ; make-primitive char->integer
60 :noname ( args -- char )
61 2dup 1 ensure-arg-count
62 car fixnum-type ensure-arg-type
65 ; make-primitive integer->char
67 : num-to-charlist ( num -- charlist )
69 [char] 0 character-type nil cons
78 dup 10 mod swap 10 / swap
80 [char] 0 + character-type 2swap
86 :noname ( args -- string )
87 2dup 1 ensure-arg-count
88 car fixnum-type ensure-arg-type
92 dup 0< swap abs ( bool num )
95 [char] - character-type 2swap cons
99 ; make-primitive number->string
101 :noname ( args -- symbol )
102 2dup 1 ensure-arg-count
103 car string-type ensure-arg-type
107 2dup car [char] - character-type objeq? if
111 2dup car [char] + character-type objeq? if
119 2dup nil objeq? false =
121 2dup car drop [char] 0 - -rot
122 2swap swap 10 * + -rot
131 ; make-primitive string->number
133 :noname ( args -- string )
134 2dup 1 ensure-arg-count
135 car symbol-type ensure-arg-type
140 ; make-primitive symbol->string
142 :noname ( args -- symbol )
143 2dup 1 ensure-arg-count
144 car string-type ensure-arg-type
149 ; make-primitive string->symbol
153 : add-prim ( args -- fixnum )
159 -rot cdr recurse drop
163 ' add-prim make-primitive +
165 :noname ( args -- fixnum )
182 :noname ( args -- fixnum )
188 -rot cdr recurse drop
193 :noname ( args -- fixnum )
194 2dup 2 ensure-arg-count
196 2dup car fixnum-type ensure-arg-type
197 2swap cdr car fixnum-type ensure-arg-type
202 ; make-primitive quotient
204 :noname ( args -- fixnum )
205 2dup 2 ensure-arg-count
207 2dup car fixnum-type ensure-arg-type
208 2swap cdr car fixnum-type ensure-arg-type
213 ; make-primitive remainder
215 ( = Pairs and Lists = )
217 :noname ( args -- pair )
218 2dup 2 ensure-arg-count
220 2dup car 2swap cdr car
222 ; make-primitive cons
224 :noname ( args -- pair )
225 2dup 1 ensure-arg-count
228 2dup car 2swap cdr car
230 ; make-primitive cons
232 :noname ( args -- pair )
233 2dup 1 ensure-arg-count
234 car pair-type ensure-arg-type
239 :noname ( args -- pair )
240 2dup 1 ensure-arg-count
241 car pair-type ensure-arg-type
246 :noname ( args -- pair )
247 2dup 2 ensure-arg-count
248 2dup car pair-type ensure-arg-type
254 ; make-primitive set-car!
256 :noname ( args -- pair )
257 2dup 2 ensure-arg-count
258 2dup car pair-type ensure-arg-type
264 ; make-primitive set-cdr!