add more std modules
This commit is contained in:
parent
f7890c07fe
commit
32252b8d89
|
@ -0,0 +1,6 @@
|
|||
-- Standard basic library for the Lamb programming language
|
||||
-- Copyright (c) 2013 darkf
|
||||
-- Licensed under the terms of the zlib license, see LICENSE for details
|
||||
|
||||
const(x) -> \_ -> x.
|
||||
compose(f, g) -> \x -> f(g(x)).
|
|
@ -0,0 +1,9 @@
|
|||
-- Standard math library for the Lamb programming language
|
||||
-- Copyright (c) 2013 darkf
|
||||
-- Licensed under the terms of the zlib license, see LICENSE for details
|
||||
|
||||
pow(base, 0) -> 1.
|
||||
pow(base, exp) -> do
|
||||
if exp < 0 then 1 / pow(base, neg(exp))
|
||||
else base * pow(base, exp-1)
|
||||
end.
|
|
@ -0,0 +1,30 @@
|
|||
-- Standard operators library for the Lamb programming language
|
||||
-- Copyright (c) 2013 darkf
|
||||
-- Licensed under the terms of the zlib license, see LICENSE for details
|
||||
|
||||
-- binary operators
|
||||
add(x,y) -> x+y.
|
||||
mul(x,y) -> x*y.
|
||||
div(x,y) -> x/y.
|
||||
|
||||
cons(x,y) -> x::y.
|
||||
|
||||
eq(x,y) -> x==y.
|
||||
neq(x,y) -> x != y.
|
||||
|
||||
lt(x,y) -> x<y.
|
||||
gt(x,y) -> x>y.
|
||||
|
||||
and(true,true) -> true.
|
||||
and(_,_) -> false.
|
||||
|
||||
or(true, _) -> true.
|
||||
or(_, true) -> true.
|
||||
or(_, _) -> false.
|
||||
|
||||
xor(true, false) -> true.
|
||||
xor(false, true) -> true.
|
||||
xor(_, _) -> false.
|
||||
|
||||
-- unary operators
|
||||
neg(x) -> 0-x.
|
Loading…
Reference in New Issue