aboutsummaryrefslogtreecommitdiff
path: root/src/PPL/Internal.hs
diff options
context:
space:
mode:
authorJustin Bedo <cu@cua0.org>2023-01-24 16:41:14 +1100
committerJustin Bedo <cu@cua0.org>2023-01-24 16:41:52 +1100
commit275ed22d5050488e6d40bb5800f1ade9c30d8a76 (patch)
treee4b5522c58074e54653df8f7bc553636577881ca /src/PPL/Internal.hs
parent190a4dc5f5398e6646823aa41637f54cc8cb54aa (diff)
don't hold onto generators
Diffstat (limited to 'src/PPL/Internal.hs')
-rw-r--r--src/PPL/Internal.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/PPL/Internal.hs b/src/PPL/Internal.hs
index de48a3f..b7d49ee 100644
--- a/src/PPL/Internal.hs
+++ b/src/PPL/Internal.hs
@@ -45,12 +45,15 @@ mutateTree :: RandomGen g => Double -> Double -> g -> Tree -> Tree
mutateTree p q g (Tree a ts) =
let (r, g1) = random g
(b, g2) = random g1
- in if r >= p
- then Tree a (mutateTrees p q g1 ts)
- else
- if r < p * q
- then Tree (1 - a) (mutateTrees p q g1 ts)
- else Tree b (mutateTrees p q g2 ts)
+ in Tree
+ ( if r >= p
+ then a
+ else
+ if r < p * q
+ then 1 - a
+ else b
+ )
+ (mutateTrees p q g2 ts)
where
mutateTrees p q g (t : ts) =
let (g1, g2) = R.split g