potatOS/src/stdlib.hvl

53 lines
851 B
Plaintext
Raw Normal View History

2021-01-29 23:33:15 +00:00
(newvar '- [(+ arg1 (negate arg2))])
(newvar '-- [(- arg1 1)])
(newvar '++ [(+ arg1 1)])
(newvar '!! [
(if arg1 [false] [true])
])
(newvar 'ztb [
(if (== arg1 0) [false] [if (== arg1 false) [false] [true]])
])
(newvar 'ifz [
(if (ztb arg1) arg2 arg3)
])
(newvar 'inz [
(if (!! (ztb arg1)) arg2 arg3)
])
(newvar '! [
(inz arg1 [1] [(*
arg1
(! (-- arg1))
)])
])
(newvar 'for [
(if (arg2 arg1) [
(arg3 arg1)
(for (++ arg1) arg2 arg3)
][true])
])
(newvar 'inrng [
(for arg1 [(< arg1 (++ arg2))] arg3)
])
(newvar 'internal_in [
(newvar 'a arg1)
(newvar 'k (keys arg1) )
(inrng 1 (len arg1) [
(arg2 (at k arg1) (at a (at k arg1)))
])
])
(newvar 'in [
(internal_in arg1 arg2)
])
('exports
'- -
'-- --
'++ ++
'ifz ifz
'inz inz
'!! !!
'! !
'for for
'inrng inrng
'in in
)