aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/time/instant.lux38
-rw-r--r--stdlib/source/test/lux.lux2
-rw-r--r--stdlib/source/test/lux/math/logic/fuzzy.lux30
-rw-r--r--stdlib/source/test/lux/time/date.lux10
4 files changed, 36 insertions, 44 deletions
diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux
index 06e11a664..9dce5f8b3 100644
--- a/stdlib/source/lux/time/instant.lux
+++ b/stdlib/source/lux/time/instant.lux
@@ -13,16 +13,16 @@
["." error (#+ Error)]
["." maybe]
[number
- ["." int ("#;." decimal)]]
- ["." text ("#;." monoid)
+ ["." int ("#@." decimal)]]
+ ["." text ("#@." monoid)
["l" lexer]]
[collection
- ["." list ("#;." fold)]
- ["." row (#+ Row row) ("#;." functor fold)]]]
+ ["." list ("#@." fold)]
+ ["." row (#+ Row row) ("#@." functor fold)]]]
[type
abstract]]
[//
- ["." duration ("#;." order)]
+ ["." duration ("#@." order)]
["." date (#+ Date)]
["." month (#+ Month)]
["." day (#+ Day)]])
@@ -105,7 +105,7 @@
duration.normal-year)]
(if (i/= +0 (duration.query year time-left))
[reference time-left]
- (if (duration;>= duration.empty time-left)
+ (if (duration@>= duration.empty time-left)
(recur (inc reference) (duration.merge (duration.inverse year) time-left))
(recur (dec reference) (duration.merge year time-left)))
))))
@@ -123,15 +123,15 @@
(def: (find-month months time)
(-> (Row Nat) duration.Duration [Nat duration.Duration])
- (if (duration;>= duration.empty time)
- (row;fold (function (_ month-days [current-month time-left])
+ (if (duration@>= duration.empty time)
+ (row@fold (function (_ month-days [current-month time-left])
(let [month-duration (duration.scale-up month-days duration.day)]
(if (i/= +0 (duration.query month-duration time-left))
[current-month time-left]
[(inc current-month) (duration.merge (duration.inverse month-duration) time-left)])))
[0 time]
months)
- (row;fold (function (_ month-days [current-month time-left])
+ (row@fold (function (_ month-days [current-month time-left])
(let [month-duration (duration.scale-up month-days duration.day)]
(if (i/= +0 (duration.query month-duration time-left))
[current-month time-left]
@@ -142,8 +142,8 @@
(def: (pad value)
(-> Int Text)
(if (i/< +10 value)
- (text;compose "0" (int;encode value))
- (int;encode value)))
+ (text@compose "0" (int@encode value))
+ (int@encode value)))
(def: (adjust-negative space duration)
(-> duration.Duration duration.Duration duration.Duration)
@@ -154,10 +154,10 @@
(def: (encode-millis millis)
(-> Int Text)
(cond (i/= +0 millis) ""
- (i/< +10 millis) ($_ text;compose ".00" (int;encode millis))
- (i/< +100 millis) ($_ text;compose ".0" (int;encode millis))
+ (i/< +10 millis) ($_ text@compose ".00" (int@encode millis))
+ (i/< +100 millis) ($_ text@compose ".0" (int@encode millis))
## (i/< +1,000 millis)
- ($_ text;compose "." (int;encode millis))))
+ ($_ text@compose "." (int@encode millis))))
(def: seconds-per-day Int (duration.query duration.second duration.day))
(def: days-up-to-epoch Int +719468)
@@ -183,7 +183,7 @@
(i/+ (i// +4 years-of-era))
(i/- (i// +100 years-of-era)))))
day-time (duration.frame duration.day offset)
- days-of-year (if (duration;>= duration.empty day-time)
+ days-of-year (if (duration@>= duration.empty day-time)
days-of-year
(dec days-of-year))
mp (|> days-of-year (i/* +5) (i/+ +2) (i// +153))
@@ -204,13 +204,13 @@
(def: #export (to-text instant)
(-> Instant Text)
(let [[[year month day] day-time] (extract-date instant)
- day-time (if (duration;>= duration.empty day-time)
+ day-time (if (duration@>= duration.empty day-time)
day-time
(duration.merge duration.day day-time))
[hours day-time] [(duration.query duration.hour day-time) (duration.frame duration.hour day-time)]
[minutes day-time] [(duration.query duration.minute day-time) (duration.frame duration.minute day-time)]
[seconds millis] [(duration.query duration.second day-time) (duration.frame duration.second day-time)]]
- ($_ text;compose (int;encode year) "-" (pad month) "-" (pad day) "T"
+ ($_ text@compose (int@encode year) "-" (pad month) "-" (pad day) "T"
(pad hours) ":" (pad minutes) ":" (pad seconds)
(|> millis
(adjust-negative duration.second)
@@ -292,7 +292,7 @@
## month-days-so-far (|> months
## row.to-list
## (list.take (.nat (dec utc-month)))
-## (list;fold n/+ 0))
+## (list@fold n/+ 0))
## total-days (|> year-days-so-far
## (i/+ (.int month-days-so-far))
## (i/+ (dec utc-day)))]]
@@ -336,7 +336,7 @@
+10 #month.November
+11 #month.December
_ (undefined))
- #date.day (.nat day)}))
+ #date.day (.nat (dec day))}))
(def: #export (month instant)
(-> Instant Month)
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index fa6a511d5..d9b3df35e 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -381,6 +381,4 @@
(<| io
_.run!
(_.times 100)
- ## (_.seed 8804587020128699091)
- ## (_.seed 9353282359333487462)
..test))
diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux
index 10b75195a..64051ffd9 100644
--- a/stdlib/source/test/lux/math/logic/fuzzy.lux
+++ b/stdlib/source/test/lux/math/logic/fuzzy.lux
@@ -116,28 +116,26 @@
right ..triangle
sample r.rev]
($_ _.and
- (_.test "Union membership as as high as membership in any of its members."
+ (_.test (%name (name-of /.union))
(let [combined (/.union left right)
combined-membership (/.membership sample combined)]
(and (r/>= (/.membership sample left)
combined-membership)
(r/>= (/.membership sample right)
combined-membership))))
- (_.test "Intersection membership as as low as membership in any of its members."
+ (_.test (%name (name-of /.intersection))
(let [combined (/.intersection left right)
combined-membership (/.membership sample combined)]
(and (r/<= (/.membership sample left)
combined-membership)
(r/<= (/.membership sample right)
combined-membership))))
- (_.test "Complement membership is the opposite of normal membership."
+ (_.test (%name (name-of /.complement))
(r/= (/.membership sample left)
(//.not (/.membership sample (/.complement left)))))
- (_.test "Membership in the difference will never be higher than in the set being subtracted."
- (bit@= (r/> (/.membership sample right)
- (/.membership sample left))
- (r/< (/.membership sample left)
- (/.membership sample (/.difference left right)))))
+ (_.test (%name (name-of /.difference))
+ (r/<= (/.membership sample right)
+ (/.membership sample (/.difference left right))))
))))
(def: predicates-and-sets
@@ -146,16 +144,12 @@
[#let [set-10 (set.from-list nat.hash (list.n/range 0 10))]
sample (|> r.nat (:: @ map (n/% 20)))]
($_ _.and
- (<| (_.context (%name (name-of /.from-predicate)))
- (_.test (format "Values that satisfy a predicate have membership = 1."
- "Values that don't have membership = 0.")
- (bit@= (r/= //.true (/.membership sample (/.from-predicate n/even?)))
- (n/even? sample))))
- (<| (_.context (%name (name-of /.from-set)))
- (_.test (format "Values that belong to a set have membership = 1."
- "Values that don't have membership = 0.")
- (bit@= (r/= //.true (/.membership sample (/.from-set set-10)))
- (set.member? set-10 sample))))
+ (_.test (%name (name-of /.from-predicate))
+ (bit@= (r/= //.true (/.membership sample (/.from-predicate n/even?)))
+ (n/even? sample)))
+ (_.test (%name (name-of /.from-set))
+ (bit@= (r/= //.true (/.membership sample (/.from-set set-10)))
+ (set.member? set-10 sample)))
)))
(def: thresholds
diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux
index 483b51388..cd03bca37 100644
--- a/stdlib/source/test/lux/time/date.lux
+++ b/stdlib/source/test/lux/time/date.lux
@@ -9,17 +9,17 @@
[/
["$." equivalence]
["$." order]
- ["$." codec]]}]
- [time
- ["@." instant]]]
+ ["$." codec]]}]]
[//
["_." instant]]
{1
- ["." / (#+ Date)]})
+ ["." / (#+ Date)
+ ["." // #_
+ ["#." instant]]]})
(def: #export date
(Random Date)
- (|> _instant.instant (:: r.monad map @instant.date)))
+ (|> _instant.instant (:: r.monad map //instant.date)))
(def: #export test
Test