From 275ed22d5050488e6d40bb5800f1ade9c30d8a76 Mon Sep 17 00:00:00 2001 From: Justin Bedo Date: Tue, 24 Jan 2023 16:41:14 +1100 Subject: don't hold onto generators --- src/PPL/Internal.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/PPL/Internal.hs') 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 -- cgit v1.2.3