x |

:drop def

drop

:comment def

“## Handy Macros ##” comment

q n | [ q match

n def ] :mdef def

call

:; def

“## Stack Manipulation Operators ##” comment

x | x x

:dup def

x y | y x

:swap def

x y | y

:nip def

x y | x y x

:dipdup def

x y z | z x y

:rot def

x y z | y z x

:-rot def

[ x | clear ]

:clear mdef

“## Combinators ##” comment

x y f | x f call y

:dip def

x y z f | x y f call z

:double-dip def

w x y z f | w x y f call z

:triple-dip def

x fa fb | x fa call x fb call

:bi def

x fa fb fc | x fa call a fb call x fc call

:tri def

q fa fb | q call fa call q call fb call

:q-bi def

x y fx fy | x fx call y fy call

:bi-call def

x y z fx fy fz | x fx call y fy call z fz call

:tri-call def

“## Numeric Operators ##” comment

-1 * +

:- def

1 +

:++ def

-1 +

:– def

1 swap [ [ dup

dip * ] times-do swap drop ] :^ def

swap <

:> def

x y | [ x y
<
=

q-bi or ] :<= def

x y | [ x y
>
=

q-bi or ] :>= def

“## String Operators ##” comment

“” [ weld

fold ] :multiWeld def

“## Boolean Operators ##” comment

x x | :true

:= def

:true :true | :true

:and def

[ :true x | :true
x :true | :true ]

:or mdef

[ :true | :nil
x | :true ]

:not mdef

= not

:!= def

x y | [ x y
!=
or

q-bi and ] :xor mdef

“## Control Flow ##” comment

[ :true x | x call
z x | ]

:if mdef

[ :true x y | x call
z x y | y call ]

:if-else mdef

[ 0 f |
n f | f call n 1 - f times-do ]

:times-do mdef

p f | p call not [ f call p f while

if ] :while def

“## Quote Functions ##” comment

@- drop

:pattern def

@- nip

:body def

@- swap >> [ swap @+

dip ] :@> def

q x | q @- swap x << swap @+

:<@ def

[ [

x f | x ] [ xs x f | xs >> x f call f fold ]] :fold mdef

[ [

f | [] ] [ xs f | xs >> [ f map ] dip f call << ]] :map mdef

[
swap <<

fold ] :reverse def

reverse [ swap <<

fold reverse ] :concat def

[

rot [ dup [ << ] dip ++ ] times-do drop ] :range def

1 swap range

:iota def