all repos — min @ 66db4625882a303b9847f316f0030fa37612095a

A small but practical concatenative programming language.

prelude.min

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
// Common Environment Variables
[os "windows" ==] 
  [
    ["HOMEPATH" $] [$HOME] :
    ["USERNAME" $] [$USER] :
  ] 
  [
    ["HOME" $] [$HOME] :
    ["USER" $] [$USER] :   
  ] 
ifte

["PATH" $]  [$PATH]     : 
[$HOME]     [$HOMEPATH] :
[$USER]     [$USERNAME] :


// Mathematical Operators
[1 +]           [succ]    :
[1 -]           [pred]    :
[2 mod 0 ==]    [even?]   :
[even? not]     [odd?]    :

[[dup 0 ==] [1 +] [dup 1 -] [ * ] linrec] [factorial] :

// Stack Operators
[swap cons]                       [swons] :
[[pop] dip]                       [popd]  :
[[dup] dip]                       [dupd]  :
[[swap] dip]                      [swapd] :
[[dup] dip i]                     [q]     :
[[zap] dip i]                     [k]     :
[[cons] dip i]                    [b]     :
[[swap] dip i]                    [c]     :
[[dip] cons cons]                 [take]  :
[[] cons dip]                     [dig1]  :
[[] cons cons dip]                [dig2]  :
[[] cons cons cons dip]           [dig3]  :
[[[] cons] dip swap i]            [bury1] :
[[[] cons cons] dip swap i]       [bury2] :
[[[] cons cons cons] dip swap i]  [bury3] :