Commit 3572915a authored by Sandra Dylus's avatar Sandra Dylus

Give helper function for assignment no. 2

parent 8fa6b33f
......@@ -3,7 +3,6 @@
> module Functional.Exercise.Exercise5 where
>
> import Functional.Lecture.InputOutput (getNumber)
> import Functional.Lecture.MoreData (inBounds)
1. In Haskell `String`s are list of `Char`s. The following definitions should transform the given string "HelloWorld" such that it yields the string specified by the comment above. You are only allow to use generic list functions like `map`, `foldr`, `filter`, but no manual pattern matching, for the implementation.
......@@ -26,13 +25,17 @@
131
The number does not meet the given bounds, please try again.
13s
The input is not a number. Please type in a number between 12 and 16.
This input is not a number, please try again.
13
Hint: You should reuse `getNumber` and `inBounds` that we defined in previous lectures.
Hint: You should reuse `getNumber` defined in the lectures as well as the helper function `inBounds` (based on an implmentation given in `Lecture.MoreData`).
> getInBounds :: Int -> Int -> IO Int
> getInBounds = error "getInBounds: Implement me!"
>
> inBounds :: Int -> (Int,Int) -> Bool
> inBounds x (xMax, xMin) = (x <= xMax) && (x >= xMin)
3. Implement a more general function `geStringtWithCondition :: (String -> Bool) IO String` that reads a string from the user and only yield this value if the string obeys to the corresponding prediate. If the predicate does not hold, the user should be informed to try it again.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment