Set 11b: fix exercise numbering

This commit is contained in:
Joel Kaasinen
2021-06-21 17:27:18 +03:00
parent dec492bfa0
commit de3d8759b9
2 changed files with 11 additions and 11 deletions
+3 -3
View File
@@ -83,7 +83,7 @@ compose :: (a -> IO b) -> (c -> IO a) -> c -> IO b
compose op1 op2 c = todo
------------------------------------------------------------------------------
-- Ex 6: Reading lines from a file. The module System.IO defines
-- Ex 5: Reading lines from a file. The module System.IO defines
-- operations for Handles, which represent open files that can be read
-- from or written to. Here are some functions that might be useful:
--
@@ -113,7 +113,7 @@ hFetchLines :: Handle -> IO [String]
hFetchLines = todo
------------------------------------------------------------------------------
-- Ex 7: Given a Handle and a list of line indexes, produce the lines
-- Ex 6: Given a Handle and a list of line indexes, produce the lines
-- at those indexes from the file.
--
-- Line indexing starts from 1.
@@ -126,7 +126,7 @@ hSelectLines :: Handle -> [Int] -> IO [String]
hSelectLines h nums = todo
------------------------------------------------------------------------------
-- Ex 8: In this exercise we see how a program can be split into a
-- Ex 7: In this exercise we see how a program can be split into a
-- pure part that does all of the work, and a simple IO wrapper that
-- drives the pure logic.
--
+8 -8
View File
@@ -23,9 +23,9 @@ tests = [(1,"appendAll",[ex1])
,(2,"swapIORefs",[ex2])
,(3,"doubleCall",[ex3_doubleCall, ex3_doubleCall_2])
,(4,"composeIO",[ex4_composeIO_1, ex4_composeIO_2])
,(6,"hFetchLines",[ex6])
,(7,"hSelectLines",[ex7_hSelectLines])
,(8,"interact'",[ex8_interact_terminates, ex8_interact_example, ex8_interact_loop])]
,(5,"hFetchLines",[ex5])
,(6,"hSelectLines",[ex6_hSelectLines])
,(7,"interact'",[ex7_interact_terminates, ex7_interact_example, ex7_interact_loop])]
-- -- -- -- --
@@ -79,7 +79,7 @@ ex4_composeIO_2 =
($ compose (return . (*2)) (return . (+1)) i) . withNoInput $
checkResult (?== (i+1)*2)
ex6 = forAllBlind (listOf1 word) $ \lines ->
ex5 = forAllBlind (listOf1 word) $ \lines ->
counterexample ("Contents of handle h:\n"++unlines lines) $
counterexample "hFetchLines h" $
monadicIO $ do
@@ -92,7 +92,7 @@ ex6 = forAllBlind (listOf1 word) $ \lines ->
run $ hClose h
stop_ $ outs ?== lines
ex7_hSelectLines =
ex6_hSelectLines =
forAllBlind (listOf1 word) $ \lines ->
forAllBlind (fmap (nub.sort) . listOf1 $ choose (1,length lines)) $ \inds ->
counterexample ("Contents of handle h:\n"++unlines lines) $
@@ -115,7 +115,7 @@ counter ("inc",n) = (True,"done",n+1)
counter ("print",n) = (True,show n,n)
counter ("quit",n) = (False,"bye bye",n)
ex8_interact_terminates =
ex7_interact_terminates =
forAllBlind word $ \w1 ->
forAllBlind word $ \w2 ->
forAllBlind (choose (0::Int,100)) $ \state ->
@@ -123,11 +123,11 @@ ex8_interact_terminates =
($ let f (input,state) = (False,input,state) in interact' f state) . withInput (unlines [w1,w2]) $
check (?==(w1++"\n")) (?==state)
ex8_interact_example =
ex7_interact_example =
$(testing' [|interact' counter 1|]) . withInput (unlines ["print","inc","inc","print","quit"]) $
check (?==unlines ["1","done","done","3","bye bye"]) (?==3)
ex8_interact_loop =
ex7_interact_loop =
forAllBlind (choose (0::Int,100)) $ \state ->
forAllBlind (choose (0::Int,5)) $ \steps ->
forAllBlind word $ \w ->