You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- So as you can see, it doesn't match the original "map"'s type and the input argument (second last "a") gets "unfolded" into [a].
74
+
--
75
+
-- 2. Another example I found is the one by https://github.com/RoccoMathijn: https://github.com/RoccoMathijn/programming-in-haskell/blob/master/chapter07.hs
76
+
--
77
+
-- map' :: (a -> b) -> [a] -> [b]
78
+
-- map' f = unfold (null) (f.head) (tail)
79
+
--
80
+
-- But this again is not intercangeable with the original "map" as b is simply [a], so the result is really [[a]].
81
+
--
82
+
-- After more time than I'd like to admit, I finally figured out the implementation which is interchangeable with the original "map".
83
+
-- Terribly inefficient, but I believe it answers the exercise's question precisely.
84
+
85
+
map':: (a->b) -> [a] -> [b]
86
+
map' f =concat. unfold null (listify . f .head) (tail)
0 commit comments