all repos — min @ bd4b5d0ccd875f3f303dd9cfc6142c7fc4840630

A small but practical concatenative programming language.

lib/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
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
(import)  (#)     sigil

; Imports
#str
#io
#logic
#num
#stack
#sys
#time
#net

; Common sigils
(bind)            (.)     sigil 
(define)          (:)     sigil 
(delete)          (~)     sigil 
(getenv)          ($)     sigil 
(system)          (!)     sigil 
(run)             (&)     sigil
(load)            (@)     sigil
(":" split call)  (%)     sigil

; Aliases
'define       ::
'bind         :.
'import       :#
'exit         :quit
'==           :eq
'!=           :noteq
'>            :gt
'<            :lt
'>=           :gte
'<=           :lte
'put          :echo
'system       :!
'run          :&
'getenv       :$
'pop          :zap
'quote        :unit
'quote        :'
'unquote      :i
'unquote      :apply
'unquote      :->
'multiunquote :multiapply
'multiunquote :->>
'scope        :=>
'filter       :select
'clear        :empty
'cons         :prepend
'size         :length

; Mathematical Operators
(1 +)           :succ
(1 -)           :pred
(2 mod 0 ==)    :even?
(even? not)     :odd?


; 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

; Other
(print pop)                                     :print!
(put pop)                                       :put!
(:ms :q :check (check) (ms sleep q) while)      :interval

; Socket constructors
((ipv4 stream tcp) socket)   :tcp-socket
((ipv6 stream tcp) socket)   :tcp6-socket
((ipv4 dgram tcp) socket)    :udp-socket
((ipv6 dgram tcp) socket)    :udp6-socket