Compare commits

..

No commits in common. "ec7ffbdd9aec4471612f909b8f6c12b7cf680560" and "6a71e3c244f29c5273a038ad7f37bf0ade9e75dd" have entirely different histories.

3 changed files with 12 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@ludus/ludus-js-pure", "name": "@ludus/ludus-js-pure",
"version": "0.1.39", "version": "0.1.37",
"description": "A Ludus interpreter in a pure JS function.", "description": "A Ludus interpreter in a pure JS function.",
"type": "module", "type": "module",
"main": "build/ludus.mjs", "main": "build/ludus.mjs",

View File

@ -81,7 +81,7 @@ fn eq? {
(x, y) -> base :eq? (x, y) (x, y) -> base :eq? (x, y)
(x, y, ...zs) -> if eq? (x, y) (x, y, ...zs) -> if eq? (x, y)
then loop (y, zs) with { then loop (y, zs) with {
(a, [b]) -> if eq? (a, x) then eq? (a, b) else false (a, []) -> eq? (a, x)
(a, [b, ...cs]) -> if eq? (a, x) (a, [b, ...cs]) -> if eq? (a, x)
then recur (b, cs) then recur (b, cs)
else false else false
@ -123,15 +123,18 @@ fn not {
(_) -> false (_) -> false
} }
fn neq? { fn neq? {
"Returns true if none of the arguments have the same value." "Returns true if none of the arguments have the same value."
(x) -> false (x) -> false
(x, y) -> not (eq? (x, y)) (x, y) -> not (eq? (x, y))
(x, y, ...zs) -> { (x, y, ...zs) -> if eq? (x, y)
let z_set = set(zs) then false
let xyz_set = ${x, y, ...z_set} else loop (y, zs) with {
eq? (count (xyz_set), add(2, count (zs))) (a, []) -> neq? (a, x)
} (a, [b, ...cs]) -> if neq? (a, x)
then recur (b, cs)
else false
}
} }
& tuples: not a lot you can do with them functionally & tuples: not a lot you can do with them functionally
@ -504,11 +507,6 @@ fn mult {
((x, y), scalar as :number) -> mult (scalar, (x, y)) ((x, y), scalar as :number) -> mult (scalar, (x, y))
} }
fn pow {
"Raises a number to the power of another number."
(x as :number, y as :number) -> base :pow (x, y)
}
fn div { fn div {
"Divides numbers. Panics on division by zero." "Divides numbers. Panics on division by zero."
(x as :number) -> x (x as :number) -> x

View File

@ -286,7 +286,6 @@
"div" / "div" /
"doc" doc "doc" doc
"downcase" string/ascii-lower "downcase" string/ascii-lower
"e" math/e
"eq?" deep= "eq?" deep=
"first" first "first" first
"floor" math/floor "floor" math/floor
@ -303,7 +302,6 @@
"nth" ludus/get "nth" ludus/get
"or" ludus/or "or" ludus/or
"pi" math/pi "pi" math/pi
"pow" math/pow
"print!" print! "print!" print!
"prn" prn "prn" prn
"push" array/push "push" array/push
@ -336,3 +334,4 @@
(set (b (keyword k)) v)) (set (b (keyword k)) v))
b)) b))
(to_number " 123 a ")