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.
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 allowed to use generic list functions like `map`, `foldr`, `filter`, but no manual pattern matching, for the implementation.
>-- str1 "HelloWorld" = "HelloWorld!"
>str1::String->String
>str1=error"str1: Implement me!"
>
>-- str2 "HelloWorld" = IfmmpXpsme"
>-- str2 "HelloWorld" = "IfmmpXpsme"
>str2::String->String
>str2=error"str2: Implement me!"
>
...
...
@@ -33,11 +33,11 @@ Hint: You should reuse `getNumber` defined in the lectures as well as the helper
>getInBounds::Int->Int->IOInt
>getInBounds=error"getInBounds: Implement me!"
>
>inBounds::Int->(Int,Int)->Bool
>inBounds::Int->((,)IntInt)->Bool
>inBoundsx(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.
3. Implement a more general function `getStringWithCondition :: (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.