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 --------------------- 1 file changed, 21 deletions(-) (limited to 'stdlib/source') 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))) -- 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 ------------------------------------- 1 file changed, 73 deletions(-) (limited to 'stdlib/source') 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)) -- cgit v1.2.3