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