I'm going through Learn You A Haskell. I have a following function:
bmiTell :: (RealFloat a) => a -> a-> String
bmiTell weight height
| bmi <= skinny ="underweight"
| bmi <= normal = "ok"
| bmi <= fat = "fat"
| otherwise = "whale"
where
bmi = weight/height^2
(skinny,normal,fat)=(18.5, 25.0,30.0)
which works perfectly fine. I'm now making a list comprehension, where a desired result is something like this:
[(68, "underweight"),(69,"ok"),(70,"ok")]
this is my ghci input:
[(x,y)| x <-[68..70], y <- bmiTell x 185]
and the output is
[(68.0,'u'),(68.0,'n'),(68.0,'d'),(68.0,'e'),(68.0,'r'),(68.0,'w'),(68.0,'e'),(68.0,'i'),(68.0,'g'),(68.0,'h'),(68.0,'t'),(69.0,'u'),(69.0,'n'),(69.0,'d'),(69.0,'e'),(69.0,'r'),(69.0,'w'),(69.0,'e'),(69.0,'i'),(69.0,'g'),(69.0,'h'),(69.0,'t'),(70.0,'u'),(70.0,'n'),(70.0,'d'),(70.0,'e'),(70.0,'r'),(70.0,'w'),(70.0,'e'),(70.0,'i'),(70.0,'g'),(70.0,'h'),(70.0,'t')]
I tried making it a (x,[y]), but I get the same result with Chars in ""s instead of single quotes
[ (x, bmiTell x 185) | x <- [68..70] ]