pow, even, odd, min, max
This commit is contained in:
18
lib/base.tri
18
lib/base.tri
@@ -246,6 +246,24 @@ mod = y (self a b :
|
||||
(_ : a)
|
||||
(_ : self (sub a b) b)))
|
||||
|
||||
pow = y (self a b :
|
||||
ifLazy
|
||||
(isZero? b)
|
||||
(_ : 1)
|
||||
(_ : mul a (self a (pred b))))
|
||||
|
||||
even? n = (triage
|
||||
true
|
||||
(_ : false)
|
||||
(bit _ : isZero? bit)
|
||||
n)
|
||||
|
||||
odd? = (n : not? (even? n))
|
||||
|
||||
min = (a b : ifLazy (lte? a b) (_ : a) (_ : b))
|
||||
|
||||
max = (a b : ifLazy (lte? a b) (_ : b) (_ : a))
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Result combinators
|
||||
-- ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user