From 74a44701e0d8fc4deb9435947788713da7c5da49 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Mon, 20 Dec 2021 15:24:19 -0500 Subject: [PATCH] Adjust Rule to use a more conventional list format --- GOL/Rule.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/GOL/Rule.hs b/GOL/Rule.hs index 7730c85..168ac98 100644 --- a/GOL/Rule.hs +++ b/GOL/Rule.hs @@ -10,8 +10,7 @@ module GOL.Rule where -- the current cell, and returns whether that cell will be -- alive in the next generation. data Rule = Rule - { - -- | A predicate deciding if an alive cell + { -- | A predicate deciding if an alive cell -- will be alive in the next generation. survive :: Int -> Bool, -- | A predicate deciding if a dead cell @@ -19,8 +18,11 @@ data Rule = Rule birth :: Int -> Bool } +-- | Construct a rule by giving lists of +-- values that satisfy each predicate. +rule :: [Int] -> [Int] -> Rule +rule s b = Rule (`elem` s) (`elem` b) -- | The standard GOL rule (S23/B3). standardRule :: Rule -standardRule = Rule (`elem` [2,3]) (== 3) - +standardRule = rule [2, 3] [3]