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
135 : add-prim ( args -- fixnum )
141 -rot cdr recurse drop
145 ' add-prim make-primitive +
147 :noname ( args -- fixnum )
153 -rot cdr add-prim drop
158 :noname ( args -- fixnum )
164 -rot cdr recurse drop