VY
Size: a a a
VY
GP
firstStep :: Grid -> Effect Step
firstStep {width, height} = do
list <- traverse (
\t@(Tuple row col) ->
(\b -> Tuple t {alive: odd row && odd col && b}) <$> randomBool)( do
row <- 1 .. width
col <- 1 .. height
pure $ Tuple row col
)
pure $ fromFoldable list
ЗП
GP
firstStep :: Grid -> Effect StepКак раз переписал
firstStep {width, height} = fromFoldable <$> traverse (
\t@(Tuple row col) ->
(\b -> Tuple t {alive: odd row && odd col && b}) <$> randomBool)( do
row <- 1 .. width
col <- 1 .. height
pure $ Tuple row col
)
GP
ЗП
lift2 Tuple (1 .. width) (1.. height) но не думаю, что это упроститЗП
ЗП
GP
type Step = Map Cell CellState
GP
GP
ЗП
traverse (
\t@(Tuple row col) ->
(\b -> Tuple t {alive: odd row && odd col && b}) <$> randomBool)
GP
ЗП
GP
AK
AK
prelude версии v4.0.0, иначе он ставил v4.1.0AK
VY
VY