foldr 이란?
foldr :: (a → b → b) → b → [a] → b
foldr [] = v
foldr f v (x:xs)
= f x ( foldr v xs )
f (x1 , ( f ( x2 , f ( x3 , [] )) )
EX>
foldr f v (x1:x1s)
= f x1 ( foldr v x1s )
= f x1 ( foldr v (x2:x2s) )
= f x1 ( f x2 ( foldr v x2s ))
foldl 이란?
foldl :: (a → a → a) → [a]→ a
foldl f v ( x : xs )
= foldl f f(v,x) xs
f ( f ( f ( v , x1) , x2 ) x3)
EX>
foldl f v ( x1 : x1s )
= foldl f f(v,x1) (x2,x2s)
= foldl f f ( f(v,x1) , x2 ) x2s
v 는 가장 처음에 f에 첫번재 파라미터로 들어가는 수
댓글 없음:
댓글 쓰기