From 7fab6e42fb986b1d66a6ab9cdf822f429224a3d3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 3 Dec 2018 23:35:02 -0400 Subject: Excised contribution relevant to this: https://github.com/LuxLang/lux/pull/35 --- stdlib/source/lux/math/random.lux | 21 --------------------- stdlib/test/test/lux/math/random.lux | 11 +---------- 2 files changed, 1 insertion(+), 31 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index ffb7bc592..b73e7df02 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -293,24 +293,3 @@ (i64.xor (i64.left-shift 14 s01))) (i64.rotate-left 36 s01)])) ("lux i64 +" s0 s1)])) - -(def: (swap from to vec) - (All [a] (-> Nat Nat (Row a) (Row a))) - (|> vec - (row.put to (maybe.assume (row.nth from vec))) - (row.put from (maybe.assume (row.nth to vec))))) - -(def: #export (shuffle seed row) - {#.doc "Shuffle a row randomly based on a seed value."} - (All [a] (-> Nat (Row a) (Row a))) - (let [_size (row.size row) - _shuffle (monad.fold Monad - (function (_ idx vec) - (do Monad - [rand nat] - (wrap (swap idx (n/% _size rand) vec)))) - row - (list.indices _size))] - (|> _shuffle - (run (pcg-32 [123 seed])) - product.right))) diff --git a/stdlib/test/test/lux/math/random.lux b/stdlib/test/test/lux/math/random.lux index f3f118c90..a7f126ef3 100644 --- a/stdlib/test/test/lux/math/random.lux +++ b/stdlib/test/test/lux/math/random.lux @@ -28,11 +28,7 @@ _set (r.set number.Hash size r.nat) _dict (r.dictionary number.Hash size r.nat r.nat) top r.nat - filtered (|> r.nat (r.filter (n/<= top))) - shuffle-seed r.nat - #let [sorted (|> _row row.to-list (list.sort n/<)) - shuffled (|> sorted row.from-list (r.shuffle shuffle-seed)) - re-sorted (|> shuffled row.to-list (list.sort n/<))]] + filtered (|> r.nat (r.filter (n/<= top)))] ($_ seq (test "Can produce lists." (n/= size (list.size _list))) @@ -50,9 +46,4 @@ (n/= size (dict.size _dict))) (test "Can filter values." (n/<= top filtered)) - (test "Can shuffle rows." - (let [(^open "v/.") (row.Equivalence number.Equivalence) - sorted (row.from-list sorted)] - (and (not (v/= sorted shuffled)) - (v/= sorted (row.from-list re-sorted))))) )))) -- cgit v1.2.3 From 53d2451a44e1241ec2c4b14e07b501156f792d71 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 3 Dec 2018 23:36:18 -0400 Subject: Excised contribution relevant to this: https://github.com/LuxLang/lux/pull/33 --- stdlib/project.clj | 1 - 1 file changed, 1 deletion(-) (limited to 'stdlib') diff --git a/stdlib/project.clj b/stdlib/project.clj index 4d01ffed4..53ad8718c 100644 --- a/stdlib/project.clj +++ b/stdlib/project.clj @@ -16,7 +16,6 @@ :scm {:name "git" :url "https://github.com/LuxLang/lux.git"} - :jvm-opts ["-Xss4m"] :dependencies [] :source-paths ["source"] -- cgit v1.2.3 From f58ab9dfeb272289989bcf5358ddb2faf273eefe Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 3 Dec 2018 23:42:02 -0400 Subject: Excised contribution relevant to this: https://github.com/LuxLang/lux/pull/34 --- stdlib/source/lux/time/duration.lux | 73 ---------------------------------- stdlib/test/test/lux/time/duration.lux | 28 +------------ 2 files changed, 1 insertion(+), 100 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index 20ef20c8c..a39e6f9ed 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -108,76 +108,3 @@ (structure: #export _ (Monoid Duration) (def: identity empty) (def: compose merge)) - -(def: (encode duration) - (-> Duration Text) - (if (:: Equivalence = empty duration) - "+0ms" - (let [signed? (negative? duration) - [days time-left] [(query day duration) (frame day duration)] - days (if signed? - (int/abs days) - days) - time-left (if signed? - (scale-up -1 time-left) - time-left) - [hours time-left] [(query hour time-left) (frame hour time-left)] - [minutes time-left] [(query minute time-left) (frame minute time-left)] - [seconds time-left] [(query second time-left) (frame second time-left)] - millis (to-millis time-left)] - ($_ text/compose - (if signed? "-" "+") - (if (i/= +0 days) "" (text/compose (nat/encode (.nat days)) "D")) - (if (i/= +0 hours) "" (text/compose (nat/encode (.nat hours)) "h")) - (if (i/= +0 minutes) "" (text/compose (nat/encode (.nat minutes)) "m")) - (if (i/= +0 seconds) "" (text/compose (nat/encode (.nat seconds)) "s")) - (if (i/= +0 millis) "" (text/compose (nat/encode (.nat millis)) "ms")) - )))) - -(def: (lex-section suffix) - (-> Text (l.Lexer Int)) - (|> (p.codec number.Codec (l.many l.decimal)) - (p.before (p.and (l.this suffix) (p.not l.alpha))) - (p.default +0))) - -(def: lex-duration - (l.Lexer Duration) - (do p.Monad - [signed? (p.or (l.this? "-") (l.this? "+")) - #let [sign (function (_ raw) - (case signed? - (#.Left _) - (i/* -1 raw) - - (#.Right _) - raw))] - utc-day (lex-section "D") - utc-hour (lex-section "h") - utc-minute (lex-section "m") - _ (p.assert "Invalid minute." - (and (i/>= +0 utc-minute) - (i/<= +59 utc-minute))) - utc-second (lex-section "s") - _ (p.assert "Invalid second." - (and (i/>= +0 utc-second) - (i/<= +59 utc-second))) - utc-millis (lex-section "ms") - _ (p.assert "Invalid milli-seconds." - (and (i/>= +0 utc-millis) - (i/<= +999 utc-millis)))] - (wrap (|> empty - (merge (scale-up (sign utc-day) day)) - (merge (scale-up (sign utc-hour) hour)) - (merge (scale-up (sign utc-minute) minute)) - (merge (scale-up (sign utc-second) second)) - (merge (scale-up (sign utc-millis) milli)))))) - -(def: (decode input) - (-> Text (e.Error Duration)) - (l.run input lex-duration)) - -(structure: #export _ - {#.doc "For example: +15D21h14m51s827ms"} - (Codec Text Duration) - (def: encode encode) - (def: decode decode)) diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux index 669af6b4c..8bf00b88b 100644 --- a/stdlib/test/test/lux/time/duration.lux +++ b/stdlib/test/test/lux/time/duration.lux @@ -57,30 +57,4 @@ (test "Merging with the empty duration changes nothing." (|> sample (@.merge @.empty) (@/= sample))) (test "Merging a duration with it's opposite yields an empty duration." - (|> sample (@.merge (@.scale-up -1 sample)) (@/= @.empty))) - (test "Can frame a duration in terms of another." - (cond (and (@.positive? frame) (@.positive? sample)) - (|> sample (@.frame frame) (@/< frame)) - - (and (@.negative? frame) (@.negative? sample)) - (|> sample (@.frame frame) (@/> frame)) - - (or (or (@.neutral? frame) (@.neutral? sample)) - (|> sample - (@.frame frame) - (@.scale-up -1) - (@/< (if (@.negative? frame) - (@.scale-up -1 frame) - frame)))))))))) - -(context: "Codec" - (<| (times 100) - (do @ - [sample duration - #let [(^open "@/.") @.Equivalence - (^open "@/.") @.Codec]] - (test "Can encode/decode durations." - (E.default #0 - (do E.Monad - [decoded (|> sample @/encode @/decode)] - (wrap (@/= sample decoded)))))))) + (|> sample (@.merge (@.scale-up -1 sample)) (@/= @.empty))))))) -- cgit v1.2.3