Skip to content

Commit 7b9ed55

Browse files
committed
Ch6 - account for another alternative solution
1 parent e81ef47 commit 7b9ed55

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

exercises/chapter6/test/Main.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Note to reader: Delete this line to expand comment block -}
181181
Assert.equal (act m1 (act m2 a))
182182
$ act (m1 <> m2) a
183183
test "concrete" do
184-
let oneOf = [ 15, 125 ]
184+
let oneOf = [ 1, 15, 125 ]
185185
got = act m1 a
186186
Assert.assert ("expected one of " <> show oneOf <> ", got " <> show got)
187187
$ elem got oneOf
@@ -209,7 +209,7 @@ Note to reader: Delete this line to expand comment block -}
209209
Assert.equal (act m1 (act m2 a))
210210
$ act (m1 <> m2) a
211211
test "concrete" do
212-
let oneOf = [[ 3, 6, 9 ], [ 1, 8, 27 ]]
212+
let oneOf = [[ 0, 0, 1], [ 3, 6, 9 ], [ 1, 8, 27 ]]
213213
got = act m1 a
214214
Assert.assert ("expected one of " <> show oneOf <> ", got " <> show got)
215215
$ elem got oneOf

exercises/chapter6/test/no-peeking/Solutions.purs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ instance actionMultiplyInt :: Action Multiply Int where
201201
act (Multiply n) m = n * m
202202

203203
{-
204-
-- Alternative solution
204+
-- Alternative solution #1
205+
instance actionMultiplyInt :: Action Multiply Int where
206+
act (Multiply n) m = m / n
207+
-}
208+
209+
{-
210+
-- Alternative solution #2
205211
import Data.Int (pow)
206212
207213
instance actionMultiplyInt :: Action Multiply Int where

0 commit comments

Comments
 (0)