aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/function/memo.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/control/function/memo.lux110
1 files changed, 55 insertions, 55 deletions
diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux
index d1be1c598..96c401be0 100644
--- a/stdlib/source/test/lux/control/function/memo.lux
+++ b/stdlib/source/test/lux/control/function/memo.lux
@@ -62,61 +62,61 @@
(do [! random.monad]
[input (|> random.nat (# ! each (|>> (n.% 5) (n.+ 21))))])
(_.for [/.Memo])
- ($_ _.and
- (_.cover [/.closed /.none]
- (io.run!
- (do io.monad
- [.let [slow (/.none n.hash ..fibonacci)
- fast (/.closed n.hash fibonacci)]
- [slow_time slow_output] (..time slow input)
- [fast_time fast_output] (..time fast input)
- .let [same_output!
- (n.= slow_output
- fast_output)
+ (all _.and
+ (_.cover [/.closed /.none]
+ (io.run!
+ (do io.monad
+ [.let [slow (/.none n.hash ..fibonacci)
+ fast (/.closed n.hash fibonacci)]
+ [slow_time slow_output] (..time slow input)
+ [fast_time fast_output] (..time fast input)
+ .let [same_output!
+ (n.= slow_output
+ fast_output)
- memo_is_faster!
- (n.< (n.+ ..wiggle_room (milli_seconds slow_time))
- (milli_seconds fast_time))]]
- (in (and same_output!
- memo_is_faster!)))))
- (_.cover [/.open]
- (io.run!
- (do io.monad
- [.let [none (/.none n.hash ..fibonacci)
- memory (dictionary.empty n.hash)
- open (/.open fibonacci)]
- [none_time none_output] (..time none input)
- [open_time [memory open_output]] (..time open [memory input])
- [open_time/+1 _] (..time open [memory (++ input)])
- .let [same_output!
- (n.= none_output
- open_output)
+ memo_is_faster!
+ (n.< (n.+ ..wiggle_room (milli_seconds slow_time))
+ (milli_seconds fast_time))]]
+ (in (and same_output!
+ memo_is_faster!)))))
+ (_.cover [/.open]
+ (io.run!
+ (do io.monad
+ [.let [none (/.none n.hash ..fibonacci)
+ memory (dictionary.empty n.hash)
+ open (/.open fibonacci)]
+ [none_time none_output] (..time none input)
+ [open_time [memory open_output]] (..time open [memory input])
+ [open_time/+1 _] (..time open [memory (++ input)])
+ .let [same_output!
+ (n.= none_output
+ open_output)
- memo_is_faster!
- (n.< (n.+ ..wiggle_room (milli_seconds none_time))
- (milli_seconds open_time))
+ memo_is_faster!
+ (n.< (n.+ ..wiggle_room (milli_seconds none_time))
+ (milli_seconds open_time))
- incrementalism_is_faster!
- (n.< (n.+ ..wiggle_room (milli_seconds open_time))
- (milli_seconds open_time/+1))]]
- (in (and same_output!
- memo_is_faster!
- incrementalism_is_faster!)))))
- (_.cover [/.memoization]
- (let [memo (<| //.fixed
- (//.mixed /.memoization)
- (is (//.Mixin Nat (State (Dictionary Nat Nat) Nat))
- (function (factorial delegate again input)
- (case input
- (^.or 0 1) (# state.monad in 1)
- _ (do state.monad
- [output' (again (-- input))]
- (in (n.* input output')))))))
- expected (|> (list.indices input)
- (list#each ++)
- (list#mix n.* 1))
- actual (|> (memo input)
- (state.result (dictionary.empty n.hash))
- product.right)]
- (n.= expected actual)))
- )))
+ incrementalism_is_faster!
+ (n.< (n.+ ..wiggle_room (milli_seconds open_time))
+ (milli_seconds open_time/+1))]]
+ (in (and same_output!
+ memo_is_faster!
+ incrementalism_is_faster!)))))
+ (_.cover [/.memoization]
+ (let [memo (<| //.fixed
+ (//.mixed /.memoization)
+ (is (//.Mixin Nat (State (Dictionary Nat Nat) Nat))
+ (function (factorial delegate again input)
+ (case input
+ (^.or 0 1) (# state.monad in 1)
+ _ (do state.monad
+ [output' (again (-- input))]
+ (in (n.* input output')))))))
+ expected (|> (list.indices input)
+ (list#each ++)
+ (list#mix n.* 1))
+ actual (|> (memo input)
+ (state.result (dictionary.empty n.hash))
+ product.right)]
+ (n.= expected actual)))
+ )))