Changes between Version 9 and Version 10 of Functions/Foldr


Ignore:
Timestamp:
Nov 15, 2018, 6:25:05 AM (3 years ago)
Author:
schiptsov
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Functions/Foldr

    v9 v10  
    33{{{foldr}}} and {{{foldl}}} are ''enzymes'' which generalize traversing and rebuilding of a list structure by taking a ''combinator'' and an ''initial value'' as parameters.
    44
     5Abstractly, {{{foldr}}} is a function that replaces all occurrences of {{{Cons}}} in a list by {{{f}}} applied to {{{x}}} and {{{xs}}}, and all occurrences of {{{Nil}}} by {{{z}}}. So,
     6{{{#!haskell
     7copy = foldr (:) []
     8}}}
     9
    510[wiki:/Functions/Map map] could be defined in terms of folding functions.
     11{{{#!haskell
     12map f = foldr ((:) . f) []
     13}}}
    614
    715see also [wiki:Folds]