File tree 1 file changed +24
-2
lines changed
1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,30 @@ b = (fmap . fmap) (++ "lol") (Just ["Hi", "Hello"])
16
16
-- Preluce> c 1
17
17
-- -2
18
18
-- Solution Note - This one is tricky since the fmap is happening over the function functor (yes, no typo there)
19
+ c :: Integer -> Integer
19
20
c = fmap (* 2 ) (\ x -> x - 2 )
20
21
22
+ -- 4. d = ((return "1" ++) . show) (\x -> [x, 1..3])
23
+ -- Prelude> d 0
24
+ -- 1[0, 1, 2, 3]
25
+ d :: Integer -> String
26
+ d = fmap ((" 1" ++ ) . show ) (\ x -> [x, 1 .. 3 ])
27
+
28
+ -- 5. e :: IO Integer
29
+ -- e = let ioi = readIO "1" :: IO Integer
30
+ -- changed = read ("123" ++) show ioi
31
+ -- in (*3) changed
32
+ -- Prelude> e
33
+ -- 3693
34
+ e :: IO Integer
35
+ e = let ioi = (readIO " 1" :: IO Integer )
36
+ changed = fmap (read . (" 123" ++ ) . show ) ioi
37
+ in fmap (* 3 ) changed
38
+
39
+ main :: IO Integer
21
40
main = do
22
- putStrLn (show a)
23
- putStrLn (show b)
41
+ print a
42
+ print b
43
+ print (c 1 )
44
+ print (d 0 )
45
+ e
You can’t perform that action at this time.
0 commit comments