diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/logic.moon | 15 | ||||
| -rw-r--r-- | lib/math.moon | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/logic.moon b/lib/logic.moon index 27fa0da..1c274dd 100644 --- a/lib/logic.moon +++ b/lib/logic.moon @@ -10,6 +10,19 @@ class BinOp extends Op for child in *@children child\update dt +class eq extends BinOp + @doc: "(eq a b [c]...) +(== a b [c]...) - check for equality" + + update: (dt) => + super\update dt + + @value = true + val = @children[1]\get! + for child in *@children[2,] + @value and= val == child\get! + + class and_ extends BinOp @doc: "(and a b [c]...) - AND values" @@ -57,6 +70,8 @@ class bool extends Op true { + '==': eq + :eq and: and_ or: or_ not: not_ diff --git a/lib/math.moon b/lib/math.moon index 35ee4de..54d3440 100644 --- a/lib/math.moon +++ b/lib/math.moon @@ -75,11 +75,14 @@ func_op = (name, arity, func) -> k.__name = name k +mod = func_op 'mod', 2, (a, b) -> a % b + module = { :add, '+': add :sub, '-': sub :mul, '*': mul :div, '/': div + :mod, '%': mod mix: func_op 'mix', 3, (a, b, i) -> i*b + (1-i)*a |
