You're right that (f . g) x = f (g x)
, but that doesn't mean that (concatMap . replicate) 4 "abc" = concatMap (replicate 4 "abc")
. Rather, it means that (concatMap . replicate) 4 "abc" = concatMap (replicate 4) "abc"
, which is true.
Got confused with point free style code
문제
So a function to replicate the elements of a list a given number of times looks like this
rep :: Int -> [a] -> [a]
rep = concatMap . replicate
by definition (f . g) x = f(g(x))
but
(concatMap (replicate 4 "abc"))
is not working same as (concatMap . replicate) 4 "abc"
. In fact it doesn't work at all. And concatMap's first parameter must be function. I'm getting confused by this. How is that point free version even working? Can anyone explain it please.
해결책
제휴하지 않습니다 StackOverflow