diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux.lux | 10 | ||||
-rw-r--r-- | stdlib/source/lux/data/collection/array.lux | 10 | ||||
-rw-r--r-- | stdlib/source/lux/time/duration.lux | 15 |
3 files changed, 33 insertions, 2 deletions
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 916b77797..1fb0afe19 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2228,7 +2228,7 @@ subjectH (high-bits subject)] (if ("lux int <" subjectH testH) #1 - (if ("lux i64 =" testH subjectH) + (if ("lux i64 =" subjectH testH) ("lux int <" (low-bits subject) (low-bits test)) @@ -6206,3 +6206,11 @@ [no yes] [off on] ) + +(def: #export nat-to-frac + (-> Nat Frac) + (|>> ..int ..int-to-frac)) + +(def: #export frac-to-nat + (-> Frac Nat) + (|>> ..frac-to-int ..nat)) diff --git a/stdlib/source/lux/data/collection/array.lux b/stdlib/source/lux/data/collection/array.lux index 6036d96ae..2e92ec64b 100644 --- a/stdlib/source/lux/data/collection/array.lux +++ b/stdlib/source/lux/data/collection/array.lux @@ -40,6 +40,16 @@ (#.Some value)))})) #.None)) +(def: #export (contains? index array) + (All [a] + (-> Nat (Array a) Bit)) + (case (..read index array) + (#.Some _) + #1 + + _ + #0)) + (def: #export (write i x xs) (All [a] (-> Nat a (Array a) (Array a))) diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index 91f262fe4..20ef20c8c 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -2,7 +2,7 @@ [lux #* [control equivalence - order + [order (#+ Order)] codec [monoid (#+ Monoid)] ["p" parser] @@ -71,6 +71,19 @@ [>= i/>=] )) + (open: "duration/." Order<Duration>) + + (do-template [<name> <op>] + [(def: #export (<name> left right) + (-> Duration Duration Duration) + (if (<op> left right) + right + left))] + + [max duration/>] + [min duration/<] + ) + (do-template [<name> <op>] [(def: #export <name> (-> Duration Bit) |