[Haskell-beginners] Function with mod cases?

Lawrence Bottorff borgauf at gmail.com
Sat Feb 6 04:18:31 UTC 2021


I'm looking through *An Introduction to Functional Programming Systems
Using Haskell *by Davie and one of the exercises is

*Define a function* f *such that*

f(x) = x + 3 (mod 5)

*Make a version that elaborates cases, as well as a straightforward way.*

I'm not really sure what's being asked, so this is what I've come up with

myMods xs = map (\x -> (x + 3) `mod` 5) xs

> myMods [1..20]
[4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3]

but when he says *make a version that elaborates cases *I'm not sure what
more there is to do.
What am I missing?

LB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20210205/e82cdc45/attachment.html>


More information about the Beginners mailing list