don't fold using builting functions
This commit is contained in:
parent
5d6d4e723d
commit
d37e51b605
10
prelude.ld
10
prelude.ld
|
@ -435,7 +435,7 @@ fn add {
|
|||
() -> 0
|
||||
(x as :number) -> x
|
||||
(x as :number, y as :number) -> base :add (x, y)
|
||||
(x, y, ...zs) -> fold (base :add, zs, base :add (x, y))
|
||||
(x, y, ...zs) -> fold (add, zs, base :add (x, y))
|
||||
& add vectors
|
||||
((x1, y1), (x2, y2)) -> (add (x1, x2), add (y1, y2))
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ fn sub {
|
|||
() -> 0
|
||||
(x as :number) -> x
|
||||
(x as :number, y as :number) -> base :sub (x, y)
|
||||
(x, y, ...zs) -> fold (base :sub, zs, base :sub (x, y))
|
||||
(x, y, ...zs) -> fold (sub, zs, base :sub (x, y))
|
||||
((x1, y1), (x2, y2)) -> (base :sub (x1, x2), base :sub (y1, y2))
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ fn mult {
|
|||
() -> 1
|
||||
(x as :number) -> x
|
||||
(x as :number, y as :number) -> base :mult (x, y)
|
||||
(x, y, ...zs) -> fold (base :mult, zs, mult (x, y))
|
||||
(x, y, ...zs) -> fold (mult, zs, mult (x, y))
|
||||
(scalar as :number, (x, y)) -> (mult (x, scalar), mult (y, scalar))
|
||||
((x, y), scalar as :number) -> mult (scalar, (x, y))
|
||||
}
|
||||
|
@ -706,7 +706,7 @@ fn and {
|
|||
() -> true
|
||||
(x) -> bool (x)
|
||||
(x, y) -> base :and (x, y)
|
||||
(x, y, ...zs) -> fold (base :and, zs, base :and (x, y))
|
||||
(x, y, ...zs) -> fold (and, zs, base :and (x, y))
|
||||
}
|
||||
|
||||
fn or {
|
||||
|
@ -714,7 +714,7 @@ fn or {
|
|||
() -> true
|
||||
(x) -> bool (x)
|
||||
(x, y) -> base :or (x, y)
|
||||
(x, y, ...zs) -> fold (base :or, zs, base :or (x, y))
|
||||
(x, y, ...zs) -> fold (or, zs, base :or (x, y))
|
||||
}
|
||||
|
||||
&&& associative collections: dicts, structs, namespaces
|
||||
|
|
Loading…
Reference in New Issue
Block a user