diff --git a/std/basic.lamb b/std/basic.lamb new file mode 100644 index 0000000..228ad2b --- /dev/null +++ b/std/basic.lamb @@ -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)). diff --git a/std/math.lamb b/std/math.lamb new file mode 100644 index 0000000..6787b6f --- /dev/null +++ b/std/math.lamb @@ -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. \ No newline at end of file diff --git a/std/op.lamb b/std/op.lamb new file mode 100644 index 0000000..5b050d9 --- /dev/null +++ b/std/op.lamb @@ -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 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.