8 % Takes an arbitrary data and puts it in $error:/errorinfo. Then calls
9 % stop to transfer control to end of nearest stopped context.
11 $error
exch /errorinfo
exch put
12 $error
/command
/throw put
19 % [obj list] -> cons -> new_list
24 lst length
1 add array
25 dup 0 elem put
% first element
26 dup 1 lst putinterval
% rest of the elements
29 % [listA listB] -> concat -> [listA... listB...]
30 /concat
{ % replaces matric concat
31 dup length
0 eq
{ %if just concat
33 }{ dup length
1 eq
{ %elseif concat of single item
43 % [obj ...] -> first -> obj
48 % [obj objs...] -> first -> [objs..]
53 % [function args... arg_list] -> apply -> result
56 args
0 get callable
% make sure function is callable
57 args
1 args length
2 sub getinterval
58 args args length
1 sub get
59 concatenate args
0 get
% stack: args function
63 % [function list] -> _map -> new_list
65 dup 0 get
exch 1 get
% stack: function list
67 callable
% make sure function is callable
68 %/new_list args length array def
71 exch dup 3 1 roll % stack: fn arg fn
72 exec exch % stack: result fn
74 pop % remove the function
75 args length array astore
80 /src_list args
0 get def
81 /new_len src_list length args length
1 sub add def
82 /new_list new_len array def
83 new_list new_len src_list length
sub src_list putinterval
84 args length
1 sub -1 1 {
86 new_list args length idx
sub 1 sub args idx get put
92 % core_ns is namespace of core functions
95 (pr
-str
) { ( ) true _pr_str_args
}
96 (str
) { () false _pr_str_args
}
97 (prn
) { ( ) true _pr_str_args print
(\n) print null
}
98 (println
) { () false _pr_str_args print
(\n) print null
}
99 (=) { dup 0 get
exch 1 get _equal?
}
100 (symbol?
) { 0 get _symbol?
}
101 (nil?
) { 0 get _nil?
}
102 (true?
) { 0 get _true?
}
103 (false?
) { 0 get _false?
}
104 (<) { dup 0 get
exch 1 get lt
}
105 (<=) { dup 0 get
exch 1 get le
}
106 (>) { dup 0 get
exch 1 get gt
}
107 (>=) { dup 0 get
exch 1 get ge
}
108 (+) { dup 0 get
exch 1 get add
}
109 (-) { dup 0 get
exch 1 get
sub }
110 (*) { dup 0 get
exch 1 get
mul }
111 (/) { dup 0 get
exch 1 get
idiv }
112 (throw
) { 0 get throw
}
113 (list
) { dup pop } % noop
114 (list?
) { 0 get _list?
}
117 (sequential?
) { 0 get _sequential?
}
118 (empty?
) { 0 get length
0 eq
}
119 (count) { 0 get length
}
120 (nth
) { dup 0 get
exch 1 get _nth
}