AZ
nmap _ [] = []
nmap f (x:xs) = x : nmap' f xs
where
nmap' _ [] = []
nmap' f (x:xs) = f x : nmap' (f . f) xs
Size: a a a
AZ
В
AZ
r
[f x | x <- xs, f <- iterate ((.) f) id]
кажется.AZ
nmap f = fmap (f . f)
?AK
AZ
r
[f x | x <- xs, f <- iterate ((.) f) id]
кажется.[f x | (x, f) <- zip xs $ iterate ((.) f) id]
AZ
[f x | (x, f) <- zip xs $ iterate ((.) f) id]
AK
AK
AZ
NL
AK
[f x | (x, f) <- zip xs $ iterate ((.) f) id]
AK
AK
NL
AK
NL
AZ
nmap f xs = nmapImpl f xs where
nmapImpl _ [] = []
nmapImpl g (x:xs) = g x : nmapImpl (f . g) xs