- , . , "" . , , Lisp, Smalltalk, Ruby, JavaScript .., reduce, Haskell.
, , Haskell , , haskell, fold .
, , " fold, ", " , ", . , - , , , .
"" Haskell foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b, , " a" Foldable f => t a , . , foldr :: (a -> b -> b) -> b -> [a] -> b. a b? (a -> b -> b) ?
Int a b: foldr :: (Int -> Int -> Int) -> Int -> [Int] -> Int wow..., ... , ? foldr int, , (+), Int ( , , Int ... Int... Int -> Int -> Int Int [Int], [Int] .. .. , [Int] ... , .
.
, , , . , ? , , foldr, Int ? foldr :: (Int -> (Int, Int) -> (Int, Int)) -> (Int, Int) -> [Int] -> (Int, Int). , , Int , Int [Int]. , next [Int], , .
foldToMinMax = foldr (\newNum (minnum,maxnum) -> (min minnum newNum, max maxnum newNum)) (maxBound :: Int, minBound :: Int)
, .
? , , , , , . , , , - : foldr :: (contentOfCollectionType -> resultType -> resultType) -> resultType -> (collectionWrapper contentOfCollectionType) -> resultType
foldr , , - . , . , .
, , , . http://happylearnhaskelltutorial.com . , , ... , , , .
, . , a Color x. , , " x " (.. x x, (+) ). , , Color x, , .
.
!