Knowledge

Fold (higher-order function)

Source 📝

132: 398:, so the final result will be the same regardless of parenthesization, although the specific way in which it is calculated will be different. In the general case of non-associative binary functions, the order in which the elements are combined may influence the final result's value. On lists, there are two obvious ways to carry this out: either by combining the first element with the result of recursively combining the rest (called a 1868:
library (one needs to be aware of the fact though that forcing a value built with a lazy data constructor won't force its constituents automatically by itself). Combined with tail recursion, such folds approach the efficiency of loops, ensuring constant space operation, when lazy evaluation of the
5415:
Scala's symbolic fold syntax was intended to resemble the left- or right-leaning tree commonly used to explain the fold operation, but has since been reinterpreted as an illustration of a toppling domino. The colon comes from a general Scala syntax mechanism whereby the apparent infix operator is
1859:
Another technical point is that, in the case of left folds using lazy evaluation, the new initial parameter is not being evaluated before the recursive call is made. This can lead to stack overflows when one reaches the end of the list and tries to evaluate the resulting potentially gigantic
429:
In practice, it is convenient and natural to have an initial value which in the case of a right fold is used when one reaches the end of the list, and in the case of a left fold is what is initially combined with the first element of the list. In the example above, the value 0 (the
368:
and structures, like various sorts of trees. One writes a function which recursively replaces the constructors of the datatype with provided functions, and any constant values of the type with provided values. Such a function is generally referred to as a
478:
chain of applications to be possible. Whether it will be left- or right-oriented will be determined by the types expected of its arguments by the combining function. If it is the second argument that must be of the same type as the result, then
581:
which transforms its last element, by applying an additional argument function to it, into a value of the result type before starting the folding itself, and is thus able to use type-asymmetrical binary operation like the regular
557:. When no initial value seems appropriate, for example, when one wants to fold the function which computes the maximum of its two parameters over a non-empty list to get the maximum element of the list, there are variants of 510:  is associative this value will be well-defined, i.e., same for any parenthesization, although the operational details of how it is calculated will be different. This can have significant impact on efficiency if 308:. Note that the parameters to cons must be flipped, because the element to add is now the right hand parameter of the combining function. Another easy result to see from this vantage-point is to write the higher-order 105:
to decide how to progressively construct a corecursive data structure, whereas a fold recursively breaks that structure down, replacing it with the results of applying a combining function at each node on its
1860:
expression. For this reason, such languages often provide a stricter variant of left folding which forces the evaluation of the initial parameter before making the recursive call. In Haskell this is the
576:
These folds use type-symmetrical binary operation: the types of both its arguments, and its result, must be the same. Richard Bird in his 2010 book proposes "a general fold function on non-empty lists"
249: 259: 722:
If the list is empty, the result is the initial value. If not, fold the tail of the list using as new initial value the result of applying f to the old initial value and the first element.
255:
There's another way to perform the structural transformation in a consistent manner, with the order of the two links of each node flipped when fed into the combining function:
5416:
invoked as a method on the left operand with the right operand passed as an argument, or vice versa if the operator's last character is a colon, here applied symmetrically.
1711:), tail-recursively building a representation of expression that right-fold would build. The extraneous intermediate list structure can be eliminated with the 4800: 6067: 522: 573:, the 1 making reference to the automatic provision of an initial element, and the fact that the lists they are applied to must have at least one element. 470:), i.e. when the type of its result is different from the type of the list's elements. Then an initial value must be used, with the same type as that of 17: 1472:
to refer to its second argument first here, and be able to produce some part of its result without reference to the recursive case (here, on its
6338: 2254:
A finite prefix of primes is concisely defined as a folding of set difference operation over the lists of enumerated multiples of integers, as
565:
which use the last and first element of the list respectively as the initial value. In Haskell and several other languages, these are called
153: 86:, and possibly some default values to be used under certain conditions. The fold then proceeds to combine elements of the data structure's 6470: 6282: 837:
If the list is empty, the result is the initial value z. If not, apply f to the first element and the result of folding the rest.
498:), and the result type is the same as the list elements' type, the parentheses may be placed in arbitrary fashion thus creating a 6317: 358: 6128: 196:, for example, are built up in many functional languages from two primitives: any list is either an empty list, commonly called 6115: 1587:
lists, that means that left-fold and reverse can be composed to perform a right fold in a tail-recursive way (cf. 
192:
Folds can be regarded as consistently replacing the structural components of a data structure with functions and values.
387:. To a rough approximation, one can think of this fold as replacing the commas in the list with the + operation, giving 1881:
interpreter, the structural transformations which fold functions perform can be illustrated by constructing a string:
402:), or by combining the result of recursively combining all elements but the last one, with the last element (called a 6475: 3107: 2248: 179: 161: 107: 6460: 1449:
can be efficiently compiled as a loop, but can't deal with infinite lists at all — it will recurse forever in an
3740: 3413: 2569: 2085: 1878: 1392:
is able to produce some part of its result without reference to the recursive case on its "right" i.e., in its
411: 226: 157: 94: 6179: 74:
processing its constituent parts, building up a return value. Typically, a fold is presented with a combining
6256: 5428: 5049: 4888: 4816: 4797: 4084: 3667: 3364: 3258: 1496:, it allows for a lazy combining function to inspect list's elements from the right, if it so chooses (e.g., 6153: 6445: 5723: 5320: 4021: 3506: 2081: 1842:
is only needed in languages like Haskell with its flipped order of arguments to the combining function of
1488:, it allows for a lazy combining function to inspect list's elements from the left; and conversely, while 6440: 6205: 6047: 5236: 5090: 3920: 3607: 3033:
value on the first iteration); the current item; the current item's index or key; and a reference to the
309: 285: 6087: 4180: 3312: 2506: 1712: 6430: 3358: 6031: 4586: 845:
Lists can be folded over in a tree-like fashion, both for finite and for indefinitely defined lists:
4965: 3853: 3181: 2364: 142: 2089: 1846:
unlike e.g., in Scheme where the same order of arguments is used for combining functions to both
526: 210: 203:), or is constructed by prefixing an element in front of another list, creating what is called a 146: 79: 5032:
R supports right folding and left or right folding with or without an initial value through the
364:
This way of looking at things provides a simple route to designing fold-like functions on other
5965: 31: 1388:
to the head of the list and the recursive case of folding over the rest of the list. Thus, if
395: 59: 4808: 1445:
will immediately call itself with new parameters until it reaches the end of the list. This
1396:
argument, and the rest of the result is never demanded, then the recursion will stop (e.g.,
1377: 515: 304:
will not change the result. The left fold diagram suggests an easy way to reverse a list,
8: 6057: 2242: 2232: 365: 67: 6393: 6294: 6110:
Richard Bird, "Pearls of Functional Algorithm Design", Cambridge University Press 2010,
1468:-applications, which is then presented to the caller to be evaluated. Were the function 70:
data structure and through use of a given combining operation, recombine the results of
6465: 6062: 6026: 2238: 6425: 5225:
Please notice that these implementations of right folds are wrong for non-commutative
6111: 5872: 4446: 3655: 2836: 431: 3913: 1084:
demand its second argument's value, at least not all of it, or not immediately (see
533:, tree-like folds are whole-list oriented and operate in a consistent manner across 6286: 4957: 4263: 2755: 2645: 546: 530: 447: 384:
with the addition operator would result in 15, the sum of the elements of the list
193: 5216:
In Ruby 1.8.7+, can also pass a symbol representing a function instead of a block.
4804: 2759: 1373: 491: 1446: 83: 5968:
can be implemented via fold, proving that iterations can be reduced to folds:
3304: 6454: 6290: 5961: 4784:
is not supplied, NULL is used, so this is not a true foldl1. Before PHP 5.3,
1450: 442:
for the left fold. For multiplication, an initial choice of 0 wouldn't work:
248: 6042: 6036: 370: 258: 111: 6363: 5645: 4334: 3810:, the folding function takes arguments in the opposite order as that for 3114: 2572: 2237:
operates on ordered lists in a local manner to efficiently produce their
499: 245:
with a specific function. These replacements can be viewed as a diagram:
115: 102: 6052: 3973: 3968: 2289: 75: 1441:). This allows right folds to operate on infinite lists. By contrast, 5599: 2075:"(1+((2+3)+(((4+5)+(6+7))+((((8+9)+(10+11))+(12+13))+0))))" 2027:"(((((1+2)+(3+4))+((5+6)+(7+8)))+(((9+10)+(11+12))+13))+0)" 1979:"(((((((((((((0+1)+2)+3)+4)+5)+6)+7)+8)+9)+10)+11)+12)+13)" 1931:"(1+(2+(3+(4+(5+(6+(7+(8+(9+(10+(11+(12+(13+0)))))))))))))" 1544:
Reversing a list is also tail-recursive (it can be implemented using
586:
to produce a result of type different from the list's elements type.
462:
The use of an initial value is necessary when the combining function
418:'s terminology. With a right fold, the sum would be parenthesized as 87: 71: 131: 4367:
without an initial value is supported in versions 10.0 and higher.
3027:
receives as arguments the result of the previous operation (or the
63: 6088:"Haskell unit 6: The higher-order fold functions | Antoni Diller" 4631: 4225: 3043: 2892: 2766: 5714:, the folding function takes arguments in the same order as for 1480:
argument), then the recursion would stop. This means that while
4372: 415: 5830: 5788: 4517: 2664: 6435: 6364:"A tutorial on the universality and expressiveness of fold" 4661: 3819: 2982: 205: 6441:"Constructing List Homomorphism from Left and Right Folds" 5710:
The supplied function takes its arguments in a tuple. For
1864:(note the apostrophe, pronounced 'prime') function in the 5418:
Scala also features the tree-like folds using the method
4707: 450:
for multiplication is 1. This would give us the outcome
422:, whereas with a left fold it would be parenthesized as 316:, by composing the function to act on the elements with 5817:
Two functions exist for each case because XPath offers
4441:
Requires Symbolic Math Toolbox, supported from R2016b.
410:
being either right-associative or left-associative, in
6318:"An intuitive feel for Scala's /: operator (foldLeft)" 2296:) could be easily defined using tree-like folding as 2080:
Infinite tree-like folding is demonstrated e.g., in
540: 4167:(either success or failure) to the return type of 1367: 237:at the end of the list with a specific value, and 1657:so it reverses the order of its arguments (i.e., 483:  could be seen as a binary operation that 6452: 121: 6426:"Higher order functions — map, fold and filter" 6280: 3912:u/y applies the dyad u between the items of y. 434:) would be chosen as an initial value, giving 6129:"Array.prototype.reduce() - JavaScript | MDN" 1072:function, to avoid its runaway evaluation on 457: 357:where the period (.) is an operator denoting 6283:"Re: Blog: My verdict on the Scala language" 1091: 525:and operate in a consistent manner for each 276:visually. They also highlight the fact that 5807:array:fold-right($ input, $ zero, $ action) 5231:(also initial value is put on wrong side). 4250:standard library object. The abbreviations 2384:could have been defined through folding as 1869:final result is impossible or undesirable. 1384:will immediately return the application of 466:  is asymmetrical in its types (e.g. 160:. Unsourced material may be challenged and 5798:array:fold-left($ input, $ zero, $ action) 4236:fold_right(Closure, Initial, List, Result) 90:, using the function in a systematic way. 6431:"Unit 6: The Higher-order fold Functions" 4231:fold_left(Closure, Initial, List, Result) 217: ), resulting from application of a 215:Cons(X1,Cons(X2,Cons(...(Cons(Xn,nil))))) 180:Learn how and when to remove this message 2475: 1653:), with a modification to the function 1456:Having reached the end of the list, an 14: 6453: 6206:"Result - Kotlin Programming Language" 6180:"reduce - Kotlin Programming Language" 2292:(and its duplicates-removing variety, 607:can be formulated in a few equations. 6104: 5803:fold-right($ input, $ zero, $ action) 3662:interface, arrays are also supported 280:is the identity function on lists (a 6315: 6154:"fold - Kotlin Programming Language" 5794:fold-left($ input, $ zero, $ action) 158:adding citations to reliable sources 125: 6394:"Getting a Fix from the Right Fold" 6339:"Fold API - Scala Standard Library" 2369:a duplicates-preserving variant of 229:). One can view a fold on lists as 24: 6361: 840: 257: 247: 221:function (written down as a colon 110:values and the recursive results ( 25: 18:Accumulate (higher-order function) 6487: 6419: 6371:Journal of Functional Programming 4161:Result.fold(onSuccess, onFailure) 2887:is an unexpanded parameter pack. 2495:Right fold without initial value 589: 541:Special folds for non-empty lists 502:of nested sub-expressions, e.g., 494:, i.e. symmetrical in its types ( 6471:Programming language comparisons 6391: 4246:Meta-predicates provided by the 2659:Similarly in all .NET languages 2492:Left fold without initial value 452:1 * 1 * 2 * 3 * 4 * 5 = 120 = 5! 406:). This corresponds to a binary 130: 27:Family of higher-order functions 6385: 6355: 6331: 6309: 5866: 4151:Other collections also support 2852: 2086:unbounded sieve of Eratosthenes 1851: 1776: 1716: 1658: 1588: 1545: 1497: 1397: 1368:Evaluation order considerations 594: 6281:Odersky, Martin (2008-01-05). 6274: 6249: 6224: 6204: 6198: 6178: 6172: 6146: 6121: 6080: 5636:ANSI Smalltalk doesn't define 4942:functools.reduce(lambda x, y: 4912:functools.reduce(lambda x, y: 545:One often wants to choose the 394:In the example above, + is an 13: 1: 6073: 5640:but many implementations do. 2971:considering the emptiness of 2945:std::ranges::fold_right_last( 2932:std::ranges::fold_left_first( 1085: 599:Using Haskell as an example, 440:((((0 + 1) + 2) + 3) + 4) + 5 436:1 + (2 + (3 + (4 + (5 + 0)))) 266: 122:As structural transformations 93:Folds are in a sense dual to 6245:from functools import reduce 6152: 2965:std::ranges::fold_right_last 2961:std::ranges::fold_left_first 2467:"last: Empty list" 2425:"head: Empty list" 7: 6048:Map (higher-order function) 6020: 3143::from-end t :initial-value 2845:is a binary operator (both 1872: 1076:defined lists the function 376: 101:value and apply a function 10: 6492: 6039:, a generalization of fold 3108:clojure.core.reducers/fold 2851:s must be the same, e.g., 2835:Fold expression (only for 1713:continuation-passing style 506:. If the binary operation 458:Linear vs. tree-like folds 265:These pictures illustrate 6032:Iterated binary operation 2500: 2497: 2494: 2491: 2488: 2485: 2482: 1464:of nested left-deepening 1092:Folds for non-empty lists 521:Whereas linear folds are 444:0 * 1 * 2 * 3 * 4 * 5 = 0 6476:Iteration in programming 6257:"Iterator in core::iter" 5970: 5940: 5881: 2915:std::ranges::fold_right( 2386: 2298: 2288:For finite lists, e.g., 2256: 2226:-- = g . g . g . g . ... 2094: 1883: 1095: 847: 724: 609: 474: 's result, for a 438:for the right fold, and 381:The folding of the list 322: 288:parlance), as replacing 58:) refers to a family of 5964:with infinite lists, a 2898:std::ranges::fold_left( 504:((1 + 2) + (3 + 4)) + 5 490:When the function is a 485:associates on the right 424:(((1 + 2) + 3) + 4) + 5 420:1 + (2 + (3 + (4 + 5))) 6461:Higher-order functions 5966:fixed point combinator 3914:"J Dictionary: Insert" 1535:"empty list" 1460:is in effect built by 1435:"empty list" 262: 252: 60:higher-order functions 32:functional programming 6133:developer.mozilla.org 5825:for structured data. 5821:for unstructured and 5577:(vector-unfold-right 4790:can only be integer. 2084:primes production by 553:as the initial value 396:associative operation 261: 251: 6316:Sterling, Nicholas. 6068:Structural recursion 5938:can be expressed as 5879:having a definition 4870:reduce(lambda x, y: 4840:reduce(lambda x, y: 2656:IEnumerable<T> 2476:In various languages 366:algebraic data types 359:function composition 154:improve this section 6058:Recursive data type 5478:(vector-fold-right 5313:DoubleEndedIterator 2231:where the function 1372:In the presence of 6343:www.scala-lang.org 6063:Reduction operator 6027:Aggregate function 5875:function. For any 4803:2020-11-28 at the 4258:may also be used. 4163:, which reduces a 3357:See also List API 3307:for example usage 2837:variadic templates 2363:with the function 487:, and vice versa. 263: 253: 6446:"The magic foldr" 6116:978-0-521-51338-8 5864: 5863: 5223:is an Enumeration 5040:arguments to the 4946:(y, x), reversed( 4929:functools.reduce( 4916:(y, x), reversed( 4895:functools.reduce( 4874:(y, x), reversed( 4844:(y, x), reversed( 4563:Array.fold_right 3656:extension methods 549:of the operation 432:additive identity 389:1 + 2 + 3 + 4 + 5 306:foldl (flip (:)) 190: 189: 182: 16:(Redirected from 6483: 6413: 6412: 6410: 6408: 6401:The Monad.Reader 6398: 6389: 6383: 6382: 6380: 6378: 6373:(9 (4)): 355–372 6368: 6362:Hutton, Graham. 6359: 6353: 6352: 6350: 6349: 6335: 6329: 6328: 6326: 6324: 6313: 6307: 6306: 6304: 6302: 6293:. Archived from 6278: 6272: 6271: 6269: 6268: 6253: 6247: 6246: 6242: 6237: 6236:import functools 6233: 6232:functools.reduce 6228: 6222: 6221: 6219: 6217: 6202: 6196: 6195: 6193: 6191: 6176: 6170: 6169: 6167: 6165: 6150: 6144: 6143: 6141: 6140: 6125: 6119: 6108: 6102: 6101: 6099: 6098: 6084: 6016: 6013: 6010: 6007: 6004: 6001: 5998: 5995: 5992: 5989: 5986: 5983: 5980: 5977: 5974: 5956: 5953: 5950: 5947: 5944: 5930: 5927: 5924: 5921: 5918: 5915: 5912: 5909: 5906: 5903: 5900: 5897: 5894: 5891: 5888: 5885: 5854: 5844: 5808: 5804: 5799: 5795: 5775: 5765: 5757: 5741: 5717: 5713: 5701: 5688: 5674: 5661: 5639: 5629: 5616: 5591: 5574: 5557: 5539: 5519: 5504: 5489: 5475: 5460: 5446: 5421: 5420:list.fold(z)(op) 5410: 5398: 5386: 5370: 5354: 5338: 5314: 5310: 5304: 5294: 5282: 5270: 5254: 5230: 5222: 5211: 5205: 5198: 5192: 5184: 5173: 5167: 5160: 5150: 5143: 5133: 5125: 5115: 5109: 5099: 5077: 5064: 5043: 5039: 5035: 5027: 5014: 5001: 4984: 4951: 4938: 4925: 4908: 4879: 4866: 4853: 4836: 4795: 4789: 4783: 4773: 4763: 4758: 4745: 4731: 4726: 4701: 4691: 4678: 4646: 4618: 4603: 4573: 4560: 4550:List.fold_right 4546: 4536:Array.fold_left 4533: 4508: 4495: 4482: 4465: 4438: 4434: 4421: 4408: 4391: 4366: 4361: 4356: 4351: 4346: 4341: 4325: 4312: 4299: 4282: 4257: 4253: 4249: 4237: 4232: 4212: 4197: 4174: 4170: 4166: 4162: 4159:. There is also 4158: 4154: 4146: 4134: 4122: 4112: 4104: 4094: 4075: 4062: 4049: 4036: 4010: 4004: 3994: 3984: 3957: 3951: 3941: 3931: 3907: 3896: 3885: 3870: 3838: 3813: 3809: 3803: 3792: 3781: 3770: 3756: 3731: 3725: 3717: 3711: 3704: 3694: 3686: 3676: 3661: 3643: 3632: 3621: 3597: 3588:iterator.unfold( 3582: 3573:iterator.reduce( 3570: 3557: 3544:list.fold_right( 3540: 3525: 3499: 3488: 3481:List.reduceBack 3477: 3467: 3456: 3442: 3429: 3400: 3383: 3348: 3331: 3294: 3277: 3253: 3245: 3240: 3231: 3218: 3216: 3200: 3172: 3160: 3148: 3132: 3101: 3088: 3076: 3060: 3038: 3032: 3026: 3014: 3000: 2976: 2970: 2966: 2962: 2954: 2941: 2928: 2911: 2886: 2880: 2879: 2876: 2873: 2870: 2867: 2864: 2861: 2858: 2855: 2850: 2844: 2830: 2818: 2806: 2787: 2756:function pointer 2753: 2746: 2740: 2734: 2728: 2722: 2710: 2693: 2692:std::accumulate( 2688: 2671: 2670:std::accumulate( 2657: 2653: 2646:extension method 2643: 2636: 2630: 2622: 2616: 2609: 2599: 2591: 2581: 2560: 2549: 2538: 2523: 2480: 2479: 2471: 2468: 2465: 2462: 2459: 2456: 2453: 2450: 2447: 2444: 2441: 2438: 2435: 2432: 2429: 2426: 2423: 2420: 2417: 2414: 2411: 2408: 2405: 2402: 2399: 2396: 2393: 2390: 2383: 2379: 2372: 2367: 2359: 2356: 2353: 2350: 2347: 2344: 2341: 2338: 2335: 2332: 2329: 2326: 2323: 2320: 2317: 2314: 2311: 2308: 2305: 2302: 2295: 2284: 2281: 2278: 2275: 2272: 2269: 2266: 2263: 2260: 2245: 2235: 2227: 2224: 2221: 2218: 2215: 2212: 2209: 2206: 2203: 2200: 2197: 2194: 2191: 2188: 2185: 2182: 2179: 2176: 2173: 2170: 2167: 2164: 2161: 2158: 2155: 2152: 2149: 2146: 2143: 2140: 2137: 2134: 2131: 2128: 2125: 2122: 2119: 2116: 2113: 2110: 2107: 2104: 2101: 2098: 2076: 2073: 2070: 2067: 2064: 2061: 2058: 2055: 2052: 2049: 2046: 2043: 2040: 2037: 2034: 2031: 2028: 2025: 2022: 2019: 2016: 2013: 2010: 2007: 2004: 2001: 1998: 1995: 1992: 1989: 1986: 1983: 1980: 1977: 1974: 1971: 1968: 1965: 1962: 1959: 1956: 1953: 1950: 1947: 1944: 1941: 1938: 1935: 1932: 1929: 1926: 1923: 1920: 1917: 1914: 1911: 1908: 1905: 1902: 1899: 1896: 1893: 1890: 1887: 1867: 1863: 1855: 1854: 1849: 1845: 1841: 1837: 1836: 1833: 1830: 1827: 1824: 1821: 1818: 1815: 1812: 1809: 1806: 1803: 1800: 1797: 1794: 1791: 1788: 1785: 1782: 1779: 1774: 1773: 1770: 1767: 1764: 1761: 1758: 1755: 1752: 1749: 1746: 1743: 1740: 1737: 1734: 1731: 1728: 1725: 1722: 1719: 1710: 1709: 1706: 1703: 1700: 1697: 1694: 1691: 1688: 1685: 1682: 1679: 1676: 1673: 1670: 1667: 1664: 1661: 1656: 1652: 1651: 1648: 1645: 1642: 1639: 1636: 1633: 1630: 1627: 1624: 1621: 1618: 1615: 1612: 1609: 1606: 1603: 1600: 1597: 1594: 1591: 1582: 1581: 1578: 1575: 1572: 1569: 1566: 1563: 1560: 1557: 1554: 1551: 1548: 1540: 1539: 1536: 1533: 1530: 1527: 1524: 1521: 1518: 1515: 1512: 1509: 1506: 1503: 1500: 1491: 1483: 1471: 1467: 1463: 1444: 1440: 1439: 1436: 1433: 1430: 1427: 1424: 1421: 1418: 1415: 1412: 1409: 1406: 1403: 1400: 1383: 1363: 1360: 1357: 1354: 1351: 1348: 1345: 1342: 1339: 1336: 1333: 1330: 1327: 1324: 1321: 1318: 1315: 1312: 1309: 1306: 1303: 1300: 1297: 1294: 1291: 1288: 1285: 1282: 1279: 1276: 1273: 1270: 1267: 1264: 1261: 1258: 1255: 1252: 1249: 1246: 1243: 1240: 1237: 1234: 1231: 1228: 1225: 1222: 1219: 1216: 1213: 1210: 1207: 1204: 1201: 1198: 1195: 1192: 1189: 1186: 1183: 1180: 1177: 1174: 1171: 1168: 1165: 1162: 1159: 1156: 1153: 1150: 1147: 1144: 1141: 1138: 1135: 1132: 1129: 1126: 1123: 1120: 1117: 1114: 1111: 1108: 1105: 1102: 1099: 1079: 1071: 1064: 1061: 1058: 1055: 1052: 1049: 1046: 1043: 1040: 1037: 1034: 1031: 1028: 1025: 1022: 1019: 1016: 1013: 1010: 1007: 1004: 1001: 998: 995: 992: 989: 986: 983: 980: 977: 974: 971: 968: 965: 962: 959: 956: 953: 950: 947: 944: 941: 938: 935: 932: 929: 926: 923: 920: 917: 914: 911: 908: 905: 902: 899: 896: 893: 890: 887: 884: 881: 878: 875: 872: 869: 866: 863: 860: 857: 854: 851: 833: 830: 827: 824: 821: 818: 815: 812: 809: 806: 803: 800: 797: 794: 791: 788: 785: 782: 779: 776: 773: 770: 767: 764: 761: 758: 755: 752: 749: 746: 743: 740: 737: 734: 731: 728: 718: 715: 712: 709: 706: 703: 700: 697: 694: 691: 688: 685: 682: 679: 676: 673: 670: 667: 664: 661: 658: 655: 652: 649: 646: 643: 640: 637: 634: 631: 628: 625: 622: 619: 616: 613: 606: 602: 585: 580: 572: 568: 564: 560: 547:identity element 505: 497: 469: 453: 448:identity element 445: 441: 437: 425: 421: 390: 386: 383: 353: 350: 347: 344: 341: 338: 335: 332: 329: 326: 319: 315: 307: 303: 295: 279: 224: 220: 216: 202: 185: 178: 174: 171: 165: 134: 126: 21: 6491: 6490: 6486: 6485: 6484: 6482: 6481: 6480: 6451: 6450: 6422: 6417: 6416: 6406: 6404: 6396: 6390: 6386: 6376: 6374: 6366: 6360: 6356: 6347: 6345: 6337: 6336: 6332: 6322: 6320: 6314: 6310: 6300: 6298: 6291:comp.scala.lang 6279: 6275: 6266: 6264: 6255: 6254: 6250: 6244: 6240: 6238: 6235: 6231: 6229: 6225: 6215: 6213: 6203: 6199: 6189: 6187: 6177: 6173: 6163: 6161: 6151: 6147: 6138: 6136: 6127: 6126: 6122: 6109: 6105: 6096: 6094: 6086: 6085: 6081: 6076: 6023: 6018: 6017: 6014: 6011: 6008: 6005: 6002: 5999: 5996: 5993: 5990: 5987: 5984: 5981: 5978: 5975: 5972: 5958: 5957: 5954: 5951: 5948: 5945: 5942: 5932: 5931: 5928: 5925: 5922: 5919: 5916: 5913: 5910: 5907: 5904: 5901: 5898: 5895: 5892: 5889: 5886: 5883: 5869: 5849: 5835: 5806: 5805: 5802: 5797: 5796: 5793: 5760: 5743: 5742: 5728: 5715: 5711: 5690: 5689: 5677: 5663: 5662: 5650: 5637: 5621: 5604: 5594:srfi/1 srfi/43 5576: 5575: 5560:(vector-unfold 5559: 5558: 5541: 5540: 5522: 5507: 5492: 5477: 5476: 5463: 5448: 5447: 5434: 5419: 5401: 5389: 5372: 5371: 5357: 5340: 5339: 5325: 5312: 5306: 5299: 5285: 5273: 5257: 5241: 5226: 5224: 5218: 5217: 5200: 5199: 5187: 5175: 5174: 5163: 5145: 5144: 5128: 5111: 5110: 5095: 5067: 5054: 5041: 5037: 5033: 5017: 5004: 4987: 4970: 4941: 4928: 4911: 4894: 4869: 4856: 4839: 4822: 4805:Wayback Machine 4791: 4785: 4779: 4761: 4748: 4729: 4712: 4699: 4683: 4666: 4636: 4606: 4591: 4562: 4561: 4549: 4535: 4534: 4523:List.fold_left 4522: 4498: 4485: 4468: 4451: 4437: 4424: 4411: 4394: 4377: 4364: 4359: 4354: 4349: 4344: 4339: 4315: 4302: 4285: 4268: 4255: 4251: 4247: 4235: 4230: 4200: 4185: 4172: 4168: 4165:Result<T> 4164: 4160: 4156: 4152: 4137: 4125: 4107: 4089: 4065: 4052: 4039: 4026: 3999: 3979: 3972: 3946: 3926: 3899: 3888: 3873: 3858: 3824: 3811: 3807: 3795: 3784: 3773: 3759: 3745: 3720: 3707: 3689: 3672: 3659: 3634: 3633: 3623: 3622: 3612: 3601: 3587: 3572: 3571: 3560: 3543: 3527: 3526: 3511: 3491: 3480: 3469: 3468: 3459: 3445: 3431: 3430: 3418: 3386: 3369: 3334: 3317: 3280: 3263: 3251: 3234: 3221: 3203: 3186: 3163: 3151: 3135: 3127::initial-value 3119: 3091: 3079: 3063: 3048: 3034: 3028: 3022: 3005: 2987: 2972: 2968: 2964: 2960: 2944: 2931: 2914: 2897: 2882: 2877: 2874: 2871: 2868: 2865: 2862: 2859: 2856: 2853: 2846: 2840: 2821: 2809: 2790: 2771: 2760:function object 2749: 2748: 2742: 2736: 2730: 2724: 2723: 2721:<numeric> 2720: 2691: 2669: 2658: 2655: 2649: 2648: 2641: 2625: 2612: 2594: 2577: 2552: 2541: 2526: 2511: 2478: 2473: 2472: 2469: 2466: 2463: 2460: 2457: 2454: 2451: 2448: 2445: 2442: 2439: 2436: 2433: 2430: 2427: 2424: 2421: 2418: 2415: 2412: 2409: 2406: 2403: 2400: 2397: 2394: 2391: 2388: 2381: 2377: 2370: 2365: 2361: 2360: 2357: 2354: 2351: 2348: 2345: 2342: 2339: 2336: 2333: 2330: 2327: 2324: 2321: 2318: 2315: 2312: 2309: 2306: 2303: 2300: 2293: 2286: 2285: 2282: 2279: 2276: 2273: 2270: 2267: 2264: 2261: 2258: 2243: 2233: 2229: 2228: 2225: 2222: 2219: 2216: 2213: 2210: 2207: 2204: 2201: 2198: 2195: 2192: 2189: 2186: 2183: 2180: 2177: 2174: 2171: 2168: 2165: 2162: 2159: 2156: 2153: 2150: 2147: 2144: 2141: 2138: 2135: 2132: 2129: 2126: 2123: 2120: 2117: 2114: 2111: 2108: 2105: 2102: 2099: 2096: 2078: 2077: 2074: 2071: 2068: 2065: 2062: 2059: 2056: 2053: 2050: 2047: 2044: 2041: 2038: 2035: 2032: 2029: 2026: 2023: 2020: 2017: 2014: 2011: 2008: 2005: 2002: 1999: 1996: 1993: 1990: 1987: 1984: 1981: 1978: 1975: 1972: 1969: 1966: 1963: 1960: 1957: 1954: 1951: 1948: 1945: 1942: 1939: 1936: 1933: 1930: 1927: 1924: 1921: 1918: 1915: 1912: 1909: 1906: 1903: 1900: 1897: 1894: 1891: 1888: 1885: 1875: 1865: 1861: 1852: 1847: 1843: 1839: 1834: 1831: 1828: 1825: 1822: 1819: 1816: 1813: 1810: 1807: 1804: 1801: 1798: 1795: 1792: 1789: 1786: 1783: 1780: 1777: 1771: 1768: 1765: 1762: 1759: 1756: 1753: 1750: 1747: 1744: 1741: 1738: 1735: 1732: 1729: 1726: 1723: 1720: 1717: 1707: 1704: 1701: 1698: 1695: 1692: 1689: 1686: 1683: 1680: 1677: 1674: 1671: 1668: 1665: 1662: 1659: 1654: 1649: 1646: 1643: 1640: 1637: 1634: 1631: 1628: 1625: 1622: 1619: 1616: 1613: 1610: 1607: 1604: 1601: 1598: 1595: 1592: 1589: 1579: 1576: 1573: 1570: 1567: 1564: 1561: 1558: 1555: 1552: 1549: 1546: 1537: 1534: 1531: 1528: 1525: 1522: 1519: 1516: 1513: 1510: 1507: 1504: 1501: 1498: 1489: 1481: 1469: 1465: 1461: 1442: 1437: 1434: 1431: 1428: 1425: 1422: 1419: 1416: 1413: 1410: 1407: 1404: 1401: 1398: 1381: 1370: 1365: 1364: 1361: 1358: 1355: 1352: 1349: 1346: 1343: 1340: 1337: 1334: 1331: 1328: 1325: 1322: 1319: 1316: 1313: 1310: 1307: 1304: 1301: 1298: 1295: 1292: 1289: 1286: 1283: 1280: 1277: 1274: 1271: 1268: 1265: 1262: 1259: 1256: 1253: 1250: 1247: 1244: 1241: 1238: 1235: 1232: 1229: 1226: 1223: 1220: 1217: 1214: 1211: 1208: 1205: 1202: 1199: 1196: 1193: 1190: 1187: 1184: 1181: 1178: 1175: 1172: 1169: 1166: 1163: 1160: 1157: 1154: 1151: 1148: 1145: 1142: 1139: 1136: 1133: 1130: 1127: 1124: 1121: 1118: 1115: 1112: 1109: 1106: 1103: 1100: 1097: 1094: 1077: 1069: 1068:In the case of 1066: 1065: 1062: 1059: 1056: 1053: 1050: 1047: 1044: 1041: 1038: 1035: 1032: 1029: 1026: 1023: 1020: 1017: 1014: 1011: 1008: 1005: 1002: 999: 996: 993: 990: 987: 984: 981: 978: 975: 972: 969: 966: 963: 960: 957: 954: 951: 948: 945: 942: 939: 936: 933: 930: 927: 924: 921: 918: 915: 912: 909: 906: 903: 900: 897: 894: 891: 888: 885: 882: 879: 876: 873: 870: 867: 864: 861: 858: 855: 852: 849: 843: 841:Tree-like folds 835: 834: 831: 828: 825: 822: 819: 816: 813: 810: 807: 804: 801: 798: 795: 792: 789: 786: 783: 780: 777: 774: 771: 768: 765: 762: 759: 756: 753: 750: 747: 744: 741: 738: 735: 732: 729: 726: 720: 719: 716: 713: 710: 707: 704: 701: 698: 695: 692: 689: 686: 683: 680: 677: 674: 671: 668: 665: 662: 659: 656: 653: 650: 647: 644: 641: 638: 635: 632: 629: 626: 623: 620: 617: 614: 611: 604: 600: 597: 592: 583: 578: 570: 566: 562: 558: 543: 503: 495: 467: 460: 451: 443: 439: 435: 423: 419: 388: 385: 382: 379: 355: 354: 351: 348: 345: 342: 339: 336: 333: 330: 327: 324: 317: 313: 305: 301: 293: 277: 222: 218: 214: 201: 186: 175: 169: 166: 151: 135: 124: 97:, which take a 28: 23: 22: 15: 12: 11: 5: 6489: 6479: 6478: 6473: 6468: 6463: 6449: 6448: 6443: 6438: 6433: 6428: 6421: 6420:External links 6418: 6415: 6414: 6392:Pope, Bernie. 6384: 6354: 6330: 6308: 6297:on 14 May 2015 6273: 6248: 6239:For reference 6230:For reference 6223: 6197: 6171: 6145: 6120: 6103: 6092:www.cantab.net 6078: 6077: 6075: 6072: 6071: 6070: 6065: 6060: 6055: 6050: 6045: 6040: 6034: 6029: 6022: 6019: 5971: 5941: 5882: 5868: 5865: 5862: 5861: 5859: 5857: 5855: 5847: 5845: 5833: 5827: 5826: 5815: 5813: 5811: 5809: 5800: 5791: 5785: 5784: 5782: 5780: 5778: 5776: 5758: 5726: 5720: 5719: 5708: 5706: 5704: 5702: 5675: 5648: 5642: 5641: 5634: 5632: 5630: 5619: 5617: 5602: 5596: 5595: 5592: 5520: 5508:(reduce-right 5505: 5490: 5461: 5432: 5425: 5424: 5413: 5411: 5399: 5387: 5355: 5323: 5317: 5316: 5297: 5295: 5289:.rev().reduce( 5283: 5271: 5255: 5239: 5233: 5232: 5214: 5212: 5185: 5161: 5126: 5093: 5087: 5086: 5084: 5082: 5080: 5078: 5065: 5052: 5046: 5045: 5030: 5028: 5015: 5002: 4985: 4968: 4962: 4961: 4954: 4952: 4939: 4926: 4909: 4892: 4885: 4884: 4882: 4880: 4867: 4854: 4837: 4820: 4813: 4812: 4776: 4774: 4764:array_reverse( 4759: 4746: 4732:array_reverse( 4727: 4710: 4704: 4703: 4696: 4694: 4692: 4681: 4679: 4664: 4658: 4657: 4655: 4653: 4651: 4649: 4647: 4634: 4628: 4627: 4625: 4623: 4621: 4619: 4604: 4589: 4583: 4582: 4580: 4578: 4576: 4574: 4547: 4520: 4514: 4513: 4511: 4509: 4496: 4483: 4466: 4449: 4443: 4442: 4439: 4435: 4422: 4409: 4392: 4375: 4369: 4368: 4362: 4357: 4352: 4347: 4342: 4337: 4331: 4330: 4328: 4326: 4313: 4300: 4283: 4266: 4260: 4259: 4244: 4242: 4240: 4238: 4233: 4228: 4222: 4221: 4219: 4217: 4215: 4213: 4198: 4183: 4177: 4176: 4149: 4147: 4135: 4123: 4105: 4087: 4081: 4080: 4078: 4076: 4063: 4050: 4037: 4024: 4018: 4017: 4015: 4013: 4011: 3997: 3995: 3977: 3965: 3964: 3962: 3960: 3958: 3944: 3942: 3924: 3917: 3916: 3910: 3908: 3897: 3886: 3871: 3856: 3850: 3849: 3847: 3845: 3843: 3841: 3839: 3822: 3816: 3815: 3804: 3793: 3782: 3771: 3757: 3743: 3737: 3736: 3734: 3732: 3718: 3705: 3687: 3670: 3664: 3663: 3652: 3650: 3648: 3646: 3644: 3627:.reduce(init, 3610: 3604: 3603: 3598: 3585: 3583: 3558: 3541: 3528:iterator.fold( 3509: 3503: 3502: 3500: 3489: 3478: 3457: 3446:List.foldBack 3443: 3416: 3410: 3409: 3407: 3405: 3403: 3401: 3384: 3367: 3361: 3360: 3355: 3353: 3351: 3349: 3332: 3315: 3309: 3308: 3301: 3299: 3297: 3295: 3278: 3261: 3255: 3254: 3248: 3246: 3232: 3219: 3201: 3184: 3178: 3177: 3175: 3173: 3161: 3149: 3133: 3117: 3111: 3110: 3104: 3102: 3089: 3077: 3061: 3046: 3040: 3039: 3019: 3017: 3015: 3003: 3001: 2985: 2979: 2978: 2957: 2955: 2942: 2929: 2912: 2895: 2889: 2888: 2833: 2831: 2819: 2807: 2788: 2769: 2763: 2762: 2717: 2715: 2713: 2711: 2689: 2667: 2661: 2660: 2639: 2637: 2623: 2610: 2592: 2575: 2566: 2565: 2563: 2561: 2550: 2539: 2524: 2509: 2503: 2502: 2499: 2496: 2493: 2490: 2487: 2484: 2477: 2474: 2387: 2299: 2257: 2249:set difference 2095: 1884: 1874: 1871: 1447:tail recursion 1369: 1366: 1096: 1093: 1090: 848: 842: 839: 725: 610: 596: 593: 591: 590:Implementation 588: 542: 539: 459: 456: 378: 375: 323: 274:fold of a list 188: 187: 138: 136: 129: 123: 120: 84:data structure 26: 9: 6: 4: 3: 2: 6488: 6477: 6474: 6472: 6469: 6467: 6464: 6462: 6459: 6458: 6456: 6447: 6444: 6442: 6439: 6437: 6436:"Fold in Tcl" 6434: 6432: 6429: 6427: 6424: 6423: 6402: 6395: 6388: 6372: 6365: 6358: 6344: 6340: 6334: 6319: 6312: 6296: 6292: 6288: 6284: 6277: 6262: 6258: 6252: 6227: 6211: 6207: 6201: 6185: 6181: 6175: 6159: 6155: 6149: 6134: 6130: 6124: 6117: 6113: 6107: 6093: 6089: 6083: 6079: 6069: 6066: 6064: 6061: 6059: 6056: 6054: 6051: 6049: 6046: 6044: 6041: 6038: 6035: 6033: 6030: 6028: 6025: 6024: 5969: 5967: 5963: 5962:lazy language 5939: 5937: 5880: 5878: 5874: 5860: 5858: 5856: 5852: 5848: 5846: 5842: 5838: 5834: 5832: 5829: 5828: 5824: 5820: 5816: 5814: 5812: 5810: 5801: 5792: 5790: 5787: 5786: 5783: 5781: 5779: 5777: 5773: 5769: 5763: 5759: 5755: 5751: 5747: 5739: 5735: 5731: 5727: 5725: 5722: 5721: 5709: 5707: 5705: 5703: 5700: 5697: 5694: 5687: 5684: 5681: 5676: 5673: 5670: 5667: 5660: 5657: 5654: 5649: 5647: 5644: 5643: 5635: 5633: 5631: 5628: 5624: 5620: 5618: 5615: 5611: 5607: 5603: 5601: 5598: 5597: 5593: 5589: 5586: 5583: 5580: 5572: 5569: 5566: 5563: 5556: 5554: 5551: 5548: 5545: 5542:unfold-right 5537: 5535: 5532: 5529: 5526: 5521: 5517: 5514: 5511: 5506: 5502: 5499: 5496: 5493:(reduce-left 5491: 5487: 5484: 5481: 5473: 5470: 5467: 5462: 5458: 5455: 5452: 5449:(vector-fold 5444: 5441: 5438: 5433: 5430: 5427: 5426: 5423: 5414: 5412: 5408: 5405:.reduceRight( 5404: 5400: 5396: 5392: 5388: 5384: 5380: 5376: 5368: 5364: 5360: 5356: 5352: 5348: 5344: 5336: 5332: 5328: 5324: 5322: 5319: 5318: 5309: 5302: 5298: 5296: 5292: 5288: 5284: 5280: 5276: 5272: 5268: 5264: 5260: 5256: 5252: 5248: 5244: 5240: 5238: 5235: 5234: 5229: 5221: 5215: 5213: 5209: 5204:.reverse_each 5203: 5196: 5191:.reverse_each 5190: 5186: 5182: 5178: 5171: 5166: 5162: 5158: 5154: 5149:.reverse_each 5148: 5141: 5137: 5132:.reverse_each 5131: 5127: 5123: 5119: 5114: 5107: 5103: 5098: 5094: 5092: 5089: 5088: 5085: 5083: 5081: 5079: 5075: 5071: 5066: 5062: 5058: 5053: 5051: 5048: 5047: 5031: 5029: 5026:, right=TRUE) 5025: 5021: 5016: 5012: 5008: 5003: 5000:, right=TRUE) 4999: 4995: 4991: 4986: 4982: 4978: 4974: 4969: 4967: 4964: 4963: 4959: 4955: 4953: 4949: 4945: 4940: 4936: 4932: 4927: 4923: 4919: 4915: 4910: 4906: 4902: 4898: 4893: 4890: 4887: 4886: 4883: 4881: 4877: 4873: 4868: 4864: 4860: 4855: 4851: 4847: 4843: 4838: 4834: 4830: 4826: 4821: 4818: 4815: 4814: 4810: 4806: 4802: 4799: 4794: 4788: 4782: 4777: 4775: 4771: 4767: 4762:array_reduce( 4760: 4756: 4752: 4749:array_reduce( 4747: 4743: 4739: 4735: 4730:array_reduce( 4728: 4724: 4720: 4716: 4713:array_reduce( 4711: 4709: 4706: 4705: 4697: 4695: 4693: 4690: 4687: 4682: 4680: 4677: 4673: 4670: 4665: 4663: 4660: 4659: 4656: 4654: 4652: 4650: 4648: 4644: 4640: 4635: 4633: 4630: 4629: 4626: 4624: 4622: 4620: 4616: 4613: 4610: 4605: 4601: 4598: 4595: 4590: 4588: 4585: 4584: 4581: 4579: 4577: 4575: 4572: 4569: 4566: 4559: 4556: 4553: 4548: 4545: 4542: 4539: 4532: 4529: 4526: 4521: 4519: 4516: 4515: 4512: 4510: 4506: 4502: 4497: 4493: 4489: 4484: 4480: 4476: 4472: 4467: 4463: 4459: 4455: 4450: 4448: 4445: 4444: 4440: 4436: 4432: 4428: 4423: 4419: 4415: 4410: 4406: 4402: 4398: 4393: 4389: 4385: 4381: 4376: 4374: 4371: 4370: 4363: 4360:NestWhileList 4358: 4353: 4348: 4343: 4338: 4336: 4333: 4332: 4329: 4327: 4323: 4319: 4314: 4310: 4306: 4301: 4297: 4293: 4289: 4284: 4280: 4276: 4272: 4267: 4265: 4262: 4261: 4245: 4243: 4241: 4239: 4234: 4229: 4227: 4224: 4223: 4220: 4218: 4216: 4214: 4210: 4207: 4204: 4201:(lists:foldr 4199: 4195: 4192: 4189: 4186:(lists:foldl 4184: 4182: 4179: 4178: 4150: 4148: 4144: 4141:.reduceRight( 4140: 4136: 4132: 4128: 4124: 4120: 4116: 4110: 4106: 4102: 4098: 4092: 4088: 4086: 4083: 4082: 4079: 4077: 4073: 4069: 4064: 4060: 4056: 4051: 4047: 4043: 4038: 4034: 4030: 4025: 4023: 4020: 4019: 4016: 4014: 4012: 4008: 4002: 3998: 3996: 3992: 3988: 3982: 3978: 3975: 3970: 3967: 3966: 3963: 3961: 3959: 3955: 3949: 3945: 3943: 3939: 3935: 3929: 3925: 3922: 3919: 3918: 3915: 3911: 3909: 3906: 3902: 3898: 3895: 3891: 3887: 3884: 3880: 3876: 3872: 3869: 3865: 3861: 3857: 3855: 3852: 3851: 3848: 3846: 3844: 3842: 3840: 3836: 3832: 3828: 3823: 3821: 3818: 3817: 3805: 3802: 3799: 3794: 3791: 3788: 3783: 3780: 3777: 3772: 3769: 3766: 3763: 3758: 3755: 3752: 3749: 3744: 3742: 3739: 3738: 3735: 3733: 3729: 3723: 3719: 3715: 3710: 3706: 3702: 3698: 3692: 3688: 3684: 3680: 3675: 3671: 3669: 3666: 3665: 3657: 3653: 3651: 3649: 3647: 3645: 3641: 3637: 3630: 3626: 3619: 3615: 3611: 3609: 3606: 3605: 3602: 3599: 3595: 3591: 3586: 3584: 3580: 3576: 3568: 3564: 3559: 3555: 3551: 3547: 3542: 3539: 3535: 3531: 3523: 3519: 3515: 3510: 3508: 3505: 3504: 3501: 3498: 3495: 3490: 3487: 3484: 3479: 3476: 3473: 3466: 3463: 3458: 3455: 3452: 3449: 3444: 3441: 3438: 3435: 3428: 3425: 3422: 3417: 3415: 3412: 3411: 3408: 3406: 3404: 3402: 3398: 3394: 3390: 3385: 3381: 3377: 3373: 3368: 3366: 3363: 3362: 3359: 3356: 3354: 3352: 3350: 3346: 3342: 3338: 3333: 3329: 3325: 3321: 3316: 3314: 3311: 3310: 3306: 3305:documentation 3302: 3300: 3298: 3296: 3292: 3288: 3284: 3279: 3275: 3271: 3267: 3262: 3260: 3257: 3256: 3252:std.algorithm 3249: 3247: 3243: 3238: 3233: 3229: 3225: 3220: 3215: 3211: 3207: 3202: 3198: 3194: 3190: 3185: 3183: 3180: 3179: 3176: 3174: 3170: 3167: 3162: 3158: 3155: 3150: 3146: 3142: 3139: 3134: 3130: 3126: 3123: 3118: 3116: 3113: 3112: 3109: 3105: 3103: 3099: 3095: 3090: 3086: 3083: 3078: 3074: 3070: 3067: 3062: 3058: 3055: 3052: 3047: 3045: 3042: 3041: 3037: 3031: 3025: 3020: 3018: 3016: 3012: 3008: 3004: 3002: 2998: 2994: 2990: 2986: 2984: 2981: 2980: 2975: 2969:std::optional 2958: 2956: 2952: 2948: 2943: 2939: 2935: 2930: 2926: 2922: 2918: 2913: 2909: 2905: 2901: 2896: 2894: 2891: 2890: 2885: 2849: 2843: 2838: 2834: 2832: 2828: 2825: 2820: 2816: 2813: 2808: 2804: 2801: 2797: 2794: 2789: 2785: 2782: 2778: 2775: 2770: 2768: 2765: 2764: 2761: 2757: 2752: 2747:are iterators 2745: 2739: 2733: 2727: 2718: 2716: 2714: 2712: 2708: 2704: 2700: 2696: 2690: 2686: 2682: 2678: 2674: 2668: 2666: 2663: 2662: 2652: 2647: 2640: 2638: 2634: 2628: 2624: 2620: 2615: 2611: 2607: 2603: 2597: 2593: 2589: 2585: 2580: 2576: 2574: 2571: 2568: 2567: 2564: 2562: 2559: 2555: 2551: 2548: 2544: 2540: 2537: 2533: 2529: 2525: 2522: 2518: 2514: 2510: 2508: 2505: 2504: 2481: 2385: 2374: 2368: 2297: 2291: 2255: 2252: 2250: 2246: 2240: 2236: 2093: 2091: 2087: 2083: 2060:"0" 2012:"0" 1964:"0" 1916:"0" 1882: 1880: 1870: 1857: 1775:; similarly, 1714: 1586: 1542: 1495: 1487: 1479: 1476:i.e., in its 1475: 1459: 1454: 1452: 1451:infinite loop 1448: 1395: 1391: 1387: 1379: 1375: 1089: 1087: 1083: 1075: 846: 838: 723: 608: 587: 574: 556: 552: 548: 538: 536: 532: 528: 524: 523:node-oriented 519: 517: 513: 509: 501: 493: 488: 486: 482: 477: 473: 465: 455: 449: 433: 427: 417: 413: 409: 405: 401: 397: 392: 374: 372: 367: 362: 360: 321: 311: 299: 291: 287: 283: 275: 273: 269: 260: 256: 250: 246: 244: 240: 236: 232: 228: 212: 208: 207: 199: 195: 184: 181: 173: 163: 159: 155: 149: 148: 144: 139:This section 137: 133: 128: 127: 119: 118:of unfolds). 117: 113: 109: 104: 103:corecursively 100: 96: 91: 89: 85: 81: 77: 73: 69: 65: 61: 57: 53: 49: 45: 41: 38:(also termed 37: 33: 19: 6405:. Retrieved 6400: 6387: 6375:. Retrieved 6370: 6357: 6346:. Retrieved 6342: 6333: 6321:. Retrieved 6311: 6299:. Retrieved 6295:the original 6276: 6265:. Retrieved 6260: 6251: 6226: 6214:. Retrieved 6209: 6200: 6188:. Retrieved 6183: 6174: 6162:. Retrieved 6157: 6148: 6137:. Retrieved 6135:. 2023-12-11 6132: 6123: 6106: 6095:. Retrieved 6091: 6082: 6043:Homomorphism 6037:Catamorphism 5959: 5935: 5933: 5876: 5870: 5867:Universality 5850: 5840: 5836: 5822: 5818: 5771: 5767: 5761: 5753: 5749: 5745: 5737: 5733: 5729: 5698: 5695: 5692: 5691:Array.foldr 5685: 5682: 5679: 5671: 5668: 5665: 5664:Array.foldl 5658: 5655: 5652: 5626: 5622: 5613: 5609: 5605: 5587: 5585:initial-seed 5584: 5581: 5578: 5570: 5568:initial-seed 5567: 5564: 5561: 5555: 5552: 5549: 5546: 5543: 5536: 5533: 5530: 5527: 5524: 5515: 5512: 5509: 5500: 5497: 5494: 5485: 5482: 5479: 5471: 5468: 5465: 5464:(fold-right 5456: 5453: 5450: 5442: 5439: 5436: 5417: 5406: 5402: 5394: 5393:.reduceLeft( 5390: 5382: 5378: 5374: 5366: 5362: 5358: 5350: 5346: 5342: 5334: 5330: 5326: 5307: 5300: 5290: 5286: 5278: 5274: 5266: 5262: 5261:.rev().fold( 5258: 5250: 5246: 5242: 5227: 5219: 5207: 5201: 5194: 5188: 5180: 5176: 5169: 5164: 5156: 5152: 5146: 5139: 5135: 5129: 5121: 5117: 5112: 5105: 5101: 5096: 5073: 5069: 5060: 5056: 5023: 5019: 5010: 5006: 4997: 4993: 4989: 4980: 4976: 4972: 4947: 4943: 4934: 4930: 4921: 4917: 4913: 4904: 4900: 4896: 4875: 4871: 4862: 4858: 4849: 4845: 4841: 4832: 4828: 4824: 4809:array_reduce 4792: 4786: 4780: 4769: 4765: 4754: 4750: 4741: 4737: 4733: 4722: 4718: 4714: 4688: 4685: 4675: 4671: 4668: 4642: 4638: 4614: 4611: 4608: 4599: 4596: 4593: 4570: 4567: 4564: 4557: 4554: 4551: 4543: 4540: 4537: 4530: 4527: 4524: 4504: 4500: 4491: 4487: 4478: 4474: 4470: 4461: 4457: 4453: 4430: 4426: 4417: 4413: 4404: 4400: 4396: 4387: 4383: 4379: 4321: 4317: 4308: 4304: 4295: 4291: 4287: 4278: 4274: 4270: 4208: 4205: 4202: 4193: 4190: 4187: 4142: 4138: 4130: 4126: 4118: 4114: 4108: 4100: 4096: 4090: 4071: 4067: 4058: 4054: 4045: 4041: 4032: 4028: 4006: 4000: 3990: 3986: 3980: 3953: 3947: 3937: 3933: 3927: 3904: 3900: 3893: 3889: 3882: 3878: 3874: 3867: 3863: 3859: 3834: 3830: 3826: 3825:Lambda.fold( 3800: 3797: 3789: 3786: 3778: 3775: 3767: 3764: 3761: 3753: 3750: 3747: 3727: 3721: 3713: 3708: 3700: 3696: 3690: 3682: 3678: 3673: 3639: 3635: 3628: 3624: 3617: 3613: 3600: 3593: 3589: 3578: 3574: 3566: 3562: 3561:list.reduce( 3553: 3549: 3545: 3537: 3533: 3529: 3521: 3517: 3513: 3496: 3493: 3485: 3482: 3474: 3471: 3464: 3461: 3460:List.reduce 3453: 3450: 3447: 3439: 3436: 3433: 3426: 3423: 3420: 3396: 3392: 3388: 3387:lists:foldr( 3379: 3375: 3371: 3370:lists:foldl( 3344: 3340: 3336: 3327: 3323: 3319: 3290: 3286: 3282: 3273: 3269: 3265: 3241: 3236: 3227: 3223: 3213: 3209: 3205: 3196: 3192: 3188: 3171::from-end t) 3168: 3165: 3156: 3153: 3144: 3140: 3137: 3128: 3124: 3121: 3097: 3093: 3084: 3081: 3072: 3068: 3065: 3056: 3053: 3050: 3035: 3029: 3023: 3010: 3006: 2996: 2992: 2988: 2973: 2950: 2946: 2937: 2933: 2924: 2920: 2916: 2907: 2903: 2899: 2883: 2847: 2841: 2826: 2823: 2814: 2811: 2802: 2799: 2795: 2792: 2783: 2780: 2776: 2773: 2750: 2743: 2737: 2731: 2725: 2706: 2702: 2698: 2694: 2684: 2680: 2676: 2672: 2650: 2632: 2626: 2618: 2613: 2605: 2601: 2595: 2587: 2583: 2578: 2557: 2553: 2546: 2542: 2535: 2531: 2527: 2520: 2516: 2512: 2375: 2362: 2287: 2253: 2230: 2079: 1876: 1858: 1584: 1543: 1493: 1486:on the right 1485: 1477: 1473: 1457: 1455: 1393: 1389: 1385: 1380:evaluation, 1371: 1081: 1074:indefinitely 1073: 1067: 844: 836: 721: 598: 595:Linear folds 575: 554: 550: 544: 534: 520: 511: 507: 489: 484: 480: 475: 471: 463: 461: 428: 407: 403: 399: 393: 380: 371:catamorphism 363: 356: 312:in terms of 310:map function 297: 289: 282:shallow copy 281: 271: 267: 264: 254: 242: 238: 234: 233:  the 230: 204: 197: 191: 176: 167: 152:Please help 140: 112:catamorphism 98: 92: 55: 51: 47: 43: 39: 35: 29: 6263:. Rust Team 6212:. Jetbrains 6186:. Jetbrains 6160:. Jetbrains 5960:Also, in a 5873:polymorphic 5646:Standard ML 5623:aCollection 5606:aCollection 5435:(fold-left 5361:.foldRight( 4335:Mathematica 3638:.partition( 3492:Seq.unfold 3470:Seq.reduce 3393:Accumulator 3376:Accumulator 3341:Accumulator 3335:List.foldr( 3324:Accumulator 3318:List.foldl( 3281:List.foldr( 3264:List.foldl( 3115:Common Lisp 2631:.Aggregate( 2617:.Aggregate( 2600:.Aggregate( 2582:.Aggregate( 2489:Right fold 1715:technique, 1494:on the left 514:  is 500:binary tree 116:anamorphism 72:recursively 6455:Categories 6348:2018-04-10 6301:14 October 6267:2021-06-22 6139:2024-01-16 6097:2023-04-04 6074:References 6053:Prefix sum 5871:Fold is a 5764:.reverse() 5513:defaultval 5498:defaultval 5329:.foldLeft( 5228:&block 5208:&block 5195:&block 5181:&block 5170:&block 5157:&block 5140:&block 5122:&block 5106:&block 5044:function. 4956:In module 4700:List::Util 4405:defaultVal 4388:defaultVal 4111:.foldRight 3974:ECMAScript 3969:JavaScript 3724:.reverse() 3693:.reverse() 3658:on Java's 3512:list.fold( 3419:List.fold 3250:in module 2719:in header 2629:.Reverse() 2598:.Reverse() 2486:Left fold 2376:Functions 2290:merge sort 1458:expression 1378:non-strict 1082:not always 537:of nodes. 516:non-strict 400:right fold 278:foldr (:) 44:accumulate 6466:Recursion 6403:(6): 5–16 6377:March 26, 6287:Newsgroup 6012:undefined 6003:undefined 5819:sequences 5600:Smalltalk 5377: :\ 5305:requires 4958:functools 4173:onFailure 4169:onSuccess 3631:(agg, e)) 3620:(agg, e)) 3432:Seq.fold 3244:.reverse) 3217:.reverse) 3106:See also 3096:(reverse 3071:(reverse 2754:can be a 2642:Aggregate 2483:Language 2301:mergesort 2239:set union 2082:recursive 1866:Data.List 1492:recurses 1484:recurses 496:a → a → a 468:a → b → b 404:left fold 239:replacing 231:replacing 200:  ( 170:June 2013 141:does not 114:, versus 88:hierarchy 68:recursive 48:aggregate 6216:29 March 6190:29 March 6164:29 March 6021:See also 5851:iterable 5837:iterable 5766:.reduce( 5746:sequence 5732:.reduce( 5638:#reduce: 5625:reduce: 5608:inject: 5523:(unfold 5311:to be a 5308:iterator 5301:iterator 5287:iterator 5277:.reduce( 5275:iterator 5259:iterator 5243:iterator 5206:.reduce( 5193:.inject( 5179:.reduce( 5168:.inject( 5151:.reduce( 5134:.inject( 5116:.reduce( 5100:.inject( 5072:initval 5059:initval 4811:online. 4801:Archived 4798:callback 4499:rreduce( 4486:lreduce( 4469:rreduce( 4452:lreduce( 4322:sequence 4309:sequence 4296:sequence 4279:sequence 4139:Iterable 4129:.reduce( 4127:Iterable 4109:Iterable 4091:Iterable 3827:iterable 3796:unfoldr 3726:.inject( 3712:.inject( 3695:.inject( 3677:.inject( 3660:Iterable 3654:All are 3636:Iterable 3625:Iterable 3614:Iterable 3575:iterator 3530:iterator 3475:sequence 3440:sequence 3164:(reduce 3152:(reduce 3136:(reduce 3120:(reduce 3092:(reduce 3080:(reduce 3064:(reduce 3049:(reduce 3009:.reduce( 2991:.reduce( 2872:<< 2866:<< 2259:primesTo 1877:Using a 1873:Examples 1838:(  1088:below). 408:operator 377:On lists 209:  108:terminal 78:, a top 76:function 52:compress 6323:24 June 6289::  6118:, p. 42 5853:.reduce 5841:initval 5768:initval 5750:initval 5744:reduce( 5734:initval 5696:initval 5683:initval 5669:initval 5656:initval 5483:initval 5469:initval 5454:initval 5440:initval 5379:initval 5363:initval 5343:initval 5331:initval 5263:initval 5247:initval 5153:initval 5136:initval 5118:initval 5102:initval 5068:(foldr 5055:(foldl 5018:Reduce( 5005:Reduce( 4998:initval 4988:Reduce( 4981:initval 4971:Reduce( 4922:initval 4905:initval 4857:reduce( 4850:initval 4833:initval 4823:reduce( 4787:initval 4781:initval 4742:initval 4723:initval 4702:module 4684:reduce 4672:initval 4667:reduce 4632:PARI/GP 4615:InitVal 4607:{FoldR 4600:InitVal 4592:{FoldL 4571:initval 4558:initval 4541:initval 4528:initval 4479:initval 4462:initval 4429:, flip( 4399:, flip( 4292:initval 4275:initval 4226:Logtalk 4115:initval 4097:initval 4003:.reduce 3991:initval 3983:.reduce 3950:.reduce 3934:initval 3930:.reduce 3883:initval 3864:initval 3835:initval 3801:initval 3785:foldr1 3774:foldl1 3765:initval 3751:initval 3741:Haskell 3697:initval 3679:initval 3590:initial 3550:initial 3534:initial 3518:initial 3497:initval 3454:initval 3437:initval 3424:initval 3235:reduce! 3222:reduce! 3210:initval 3204:reduce! 3193:initval 3187:reduce! 3145:initval 3129:initval 3069:initval 3054:initval 3044:Clojure 3030:initial 2997:initial 2967:return 2921:initval 2904:initval 2803:initval 2774:initval 2703:initval 2681:initval 2602:initval 2584:initval 2536:initval 2517:initval 2498:Unfold 2331:nubsort 2294:nubsort 2090:Haskell 1879:Haskell 1086:example 412:Haskell 227:Haskell 213:(  162:removed 147:sources 95:unfolds 64:analyze 6407:May 1, 6241:reduce 6210:Kotlin 6184:Kotlin 6158:Kotlin 6114:  6009:repeat 5839:.fold( 5823:arrays 5678:foldr 5651:foldl 5627:aBlock 5614:aBlock 5612:into: 5610:aValue 5582:length 5565:length 5486:vector 5457:vector 5429:Scheme 5303:.rev() 5245:.fold( 5050:Racket 5042:Reduce 4889:Python 4817:Python 4807:. Try 4637:fold( 4447:Maxima 4425:fold(@ 4412:fold(@ 4395:fold(@ 4378:fold(@ 4373:MATLAB 4316:foldr( 4303:foldl( 4286:foldr( 4269:foldl( 4157:reduce 4085:Kotlin 4066:foldr( 4053:foldl( 4040:foldr( 4027:foldl( 3948:stream 3928:stream 3760:foldr 3746:foldl 3668:Groovy 3616:.fold( 3365:Erlang 3259:Elixir 3021:Where 2738:rbegin 2695:rbegin 2654:is an 2644:is an 2558:vector 2547:vector 2532:vector 2521:vector 2501:Notes 2268:foldl1 2247:their 2241:, and 2097:primes 2054:concat 2006:concat 1958:concat 1910:concat 1862:foldl' 1585:finite 1583:). On 1394:second 1344:foldi1 1311:foldi1 1299:foldi1 1266:foldt1 1236:foldt1 1224:foldt1 1212:foldr1 1179:foldr1 1167:foldr1 1140:foldl1 1110:foldl1 1098:foldl1 579:foldrn 571:foldl1 567:foldr1 535:groups 476:linear 446:. The 416:Prolog 414:'s or 320:, as: 56:inject 40:reduce 6397:(PDF) 6367:(PDF) 5994:-> 5982:foldr 5949:foldr 5934:then 5831:Xtend 5789:XPath 5762:array 5730:array 5724:Swift 5716:foldr 5712:foldl 5699:array 5672:array 5321:Scala 5034:right 4796:is a 4778:When 4766:array 4751:array 4734:array 4715:array 4686:block 4669:block 4568:array 4544:array 4518:OCaml 4355:Fold] 4345:Fold] 4264:Maple 4256:foldr 4252:foldl 4206:accum 4191:accum 4093:.fold 4022:Julia 4001:array 3981:array 3905:array 3894:array 3892:~/|. 3879:array 3868:array 3862:~/|. 3812:foldr 3808:foldl 3507:Gleam 2974:range 2959:Both 2947:range 2934:range 2917:range 2900:range 2893:C++23 2810:(... 2767:C++17 2758:or a 2726:begin 2673:begin 2651:ienum 2627:ienum 2614:ienum 2596:ienum 2579:ienum 2464:error 2452:-> 2437:foldl 2422:error 2410:-> 2395:foldr 2371:union 2366:merge 2352:<- 2343:union 2340:foldt 2322:<- 2313:merge 2310:foldt 2280:<- 2271:minus 2244:minus 2234:union 2196:-> 2169:union 2160:-> 2133:foldi 2127:minus 2051:-> 2036:foldi 2003:-> 1988:foldt 1955:-> 1940:foldl 1907:-> 1892:foldr 1853:foldr 1848:foldl 1844:foldl 1808:-> 1793:foldr 1778:foldl 1748:-> 1733:foldl 1718:foldr 1693:foldl 1672:foldl 1660:foldr 1647:<+ 1638:<+ 1629:<+ 1611:+> 1602:+> 1593:+> 1568:-> 1553:foldl 1532:error 1520:-> 1505:foldl 1490:foldl 1482:foldr 1478:first 1462:foldl 1443:foldl 1432:error 1420:-> 1405:foldr 1382:foldr 1376:, or 1353:pairs 1287:pairs 1080:must 1070:foldi 1051:pairs 1042:pairs 1000:pairs 988:pairs 976:foldi 940:foldi 925:foldi 913:pairs 901:foldt 886:foldt 865:foldt 850:foldt 820:foldr 784:foldr 769:foldr 763:-> 760:-> 754:-> 745:-> 739:-> 727:foldr 696:foldl 669:foldl 654:foldl 648:-> 645:-> 639:-> 630:-> 624:-> 612:foldl 605:foldr 601:foldl 584:foldr 563:foldl 559:foldr 529:of a 492:magma 334:foldr 314:foldr 300:with 292:with 268:right 241:each 194:Lists 82:of a 62:that 54:, or 6409:2011 6379:2009 6325:2016 6303:2013 6261:Rust 6218:2019 6192:2019 6166:2019 6112:ISBN 5772:func 5754:func 5738:func 5693:func 5686:list 5680:func 5666:func 5659:list 5653:func 5553:seed 5534:seed 5516:list 5510:func 5501:list 5495:func 5480:func 5472:list 5466:func 5451:func 5443:list 5437:func 5431:RRS 5407:func 5403:list 5395:func 5391:list 5383:func 5375:list 5367:func 5359:list 5351:func 5347:list 5335:func 5327:list 5291:func 5279:func 5267:func 5251:func 5237:Rust 5220:enum 5202:enum 5189:enum 5177:enum 5165:enum 5147:enum 5130:enum 5113:enum 5097:enum 5091:Ruby 5074:list 5070:func 5061:list 5057:func 5038:init 5036:and 5024:list 5020:func 5011:list 5007:func 4994:list 4990:func 4977:list 4973:func 4948:list 4944:func 4935:list 4931:func 4918:list 4914:func 4901:list 4897:func 4891:3.x 4876:list 4872:func 4863:list 4859:func 4846:list 4842:func 4829:list 4825:func 4819:2.x 4793:func 4770:func 4755:func 4738:func 4719:func 4689:list 4676:list 4662:Perl 4612:Func 4609:List 4597:Func 4594:List 4565:func 4555:list 4552:func 4538:func 4531:list 4525:func 4505:list 4501:func 4492:list 4488:func 4475:list 4471:func 4458:list 4454:func 4431:list 4427:func 4418:list 4414:func 4401:list 4397:func 4384:list 4380:func 4365:Fold 4350:Fold 4340:Fold 4318:func 4305:func 4288:func 4271:func 4254:and 4248:meta 4209:list 4203:func 4194:list 4188:func 4171:and 4155:and 4153:fold 4143:func 4131:func 4119:func 4101:func 4007:func 3987:func 3954:func 3938:func 3921:Java 3901:verb 3890:verb 3875:verb 3860:verb 3831:func 3820:Haxe 3806:For 3798:func 3790:list 3787:func 3779:list 3776:func 3768:list 3762:func 3754:list 3748:func 3728:func 3722:list 3714:func 3709:list 3701:func 3691:list 3683:func 3674:list 3642:(e)) 3608:Gosu 3594:func 3579:func 3567:func 3563:list 3554:func 3546:list 3538:func 3522:func 3514:list 3494:func 3486:list 3483:func 3472:func 3465:list 3462:func 3451:list 3448:func 3434:func 3427:list 3421:func 3397:List 3380:List 3345:List 3328:List 3303:See 3283:list 3266:list 3242:list 3237:func 3228:list 3224:func 3214:list 3206:func 3197:list 3189:func 3169:list 3166:func 3157:list 3154:func 3141:list 3138:func 3125:list 3122:func 3098:list 3094:func 3085:list 3082:func 3073:list 3066:func 3057:list 3051:func 3024:func 3011:func 2993:func 2983:CFML 2963:and 2951:func 2938:func 2925:func 2908:func 2884:pack 2875:args 2863:cout 2829:...) 2824:pack 2815:pack 2798:... 2793:pack 2784:pack 2779:... 2751:func 2744:rend 2707:func 2699:rend 2685:func 2633:func 2619:func 2606:func 2588:func 2554:func 2543:func 2528:func 2513:func 2431:last 2389:head 2382:last 2380:and 2378:head 2069:show 2033:> 2021:show 1985:> 1973:show 1937:> 1925:show 1889:> 1850:and 1840:flip 1817:flip 1699:flip 1678:flip 1499:last 1474:left 1399:head 1374:lazy 603:and 569:and 561:and 531:list 527:node 318:cons 296:and 294:cons 290:cons 286:Lisp 272:left 270:and 243:cons 219:cons 211:node 206:cons 145:any 143:cite 99:seed 80:node 36:fold 5588:··· 5571:··· 5345:/: 4920:), 4848:), 4768:), 4736:), 4708:PHP 4698:in 4403:), 4181:LFE 4072:itr 4059:itr 4048:; ) 4046:itr 4035:; ) 4033:itr 3971:1.8 3923:8+ 3389:Fun 3372:Fun 3337:Fun 3320:Fun 3313:Elm 3291:fun 3287:acc 3274:fun 3270:acc 3036:obj 3007:obj 2989:obj 2881:), 2869:... 2857:std 2839:): 2732:end 2677:end 2665:C++ 2573:3.0 2545:⍨/⌽ 2515:⍨/⌽ 2507:APL 2184:map 2088:in 2066:map 2018:map 1970:map 1922:map 1856:). 1547:rev 1541:). 454:. 325:map 302:nil 298:nil 284:in 235:nil 225:in 223:(:) 198:nil 156:by 30:In 6457:: 6399:. 6369:. 6341:. 6285:. 6259:. 6243:: 6234:: 6208:. 6182:. 6156:. 6131:. 6090:. 5926:xs 5905:xs 5843:,) 5770:, 5752:, 5748:, 5736:, 5718:. 5422:. 5381:)( 5365:)( 5349:)( 5333:)( 5315:. 5265:, 5249:, 5155:, 5138:, 5120:, 5104:, 5022:, 5009:, 4996:, 4992:, 4979:, 4975:, 4960:. 4950:)) 4933:, 4903:, 4899:, 4878:)) 4861:, 4831:, 4827:, 4753:, 4740:, 4721:, 4717:, 4674:, 4641:, 4587:Oz 4503:, 4490:, 4477:, 4473:, 4460:, 4456:, 4433:)) 4416:, 4386:, 4382:, 4320:, 4307:, 4294:, 4290:, 4277:, 4273:, 4175:. 4117:, 4099:, 4070:, 4068:op 4057:, 4055:op 4044:, 4042:op 4031:, 4029:op 3989:, 3976:5 3936:, 3903:/ 3877:/ 3833:, 3829:, 3814:. 3699:, 3681:, 3592:, 3577:, 3565:, 3552:, 3548:, 3536:, 3532:, 3520:, 3516:, 3414:F# 3395:, 3391:, 3378:, 3374:, 3343:, 3339:, 3326:, 3322:, 3289:, 3285:, 3272:, 3268:, 3212:, 3195:, 3100:)) 3075:)) 2995:, 2977:. 2949:, 2936:, 2923:, 2919:, 2906:, 2902:, 2860::: 2848:op 2842:op 2827:op 2812:op 2800:op 2796:op 2781:op 2777:op 2741:, 2735:, 2729:, 2705:, 2701:, 2697:, 2683:, 2679:, 2675:, 2604:, 2586:, 2570:C# 2373:. 2355:xs 2334:xs 2325:xs 2304:xs 2251:. 2217:_Y 2202:_Y 2199:)) 2175:ys 2172:xs 2157:ys 2151:xs 2112:(( 2109:_Y 2092:: 1832:xs 1829:id 1790:== 1787:xs 1769:xs 1766:id 1730:== 1727:xs 1708:)) 1669:== 1623:(( 1620:== 1617:)) 1577:ys 1562:ys 1502:== 1453:. 1402:== 1362:)) 1359:xs 1326:xs 1293:xs 1257:xs 1218:xs 1194:xs 1161:xs 1131:xs 997:)) 994:xs 958:xs 919:xs 895:xs 829:xs 802:xs 730::: 717:xs 687:xs 615::: 518:. 426:. 391:. 373:. 361:. 337:(( 66:a 50:, 46:, 42:, 34:, 6411:. 6381:. 6351:. 6327:. 6305:. 6270:. 6220:. 6194:. 6168:. 6142:. 6100:. 6015:) 6006:( 6000:) 5997:f 5991:_ 5988:\ 5985:( 5979:= 5976:f 5973:y 5955:v 5952:f 5946:= 5943:g 5936:g 5929:) 5923:g 5920:( 5917:x 5914:f 5911:= 5908:) 5902:: 5899:x 5896:( 5893:g 5890:v 5887:= 5884:g 5877:g 5774:) 5756:) 5740:) 5590:) 5579:f 5573:) 5562:f 5550:g 5547:f 5544:p 5538:) 5531:g 5528:f 5525:p 5518:) 5503:) 5488:) 5474:) 5459:) 5445:) 5409:) 5397:) 5385:) 5373:( 5369:) 5353:) 5341:( 5337:) 5293:) 5281:) 5269:) 5253:) 5210:) 5197:) 5183:) 5172:) 5159:) 5142:) 5124:) 5108:) 5076:) 5063:) 5013:) 4983:) 4966:R 4937:) 4924:) 4907:) 4865:) 4852:) 4835:) 4772:) 4757:) 4744:) 4725:) 4645:) 4643:A 4639:f 4617:} 4602:} 4507:) 4494:) 4481:) 4464:) 4420:) 4407:) 4390:) 4324:) 4311:) 4298:) 4281:) 4211:) 4196:) 4145:) 4133:) 4121:) 4113:( 4103:) 4095:( 4074:) 4061:) 4009:) 4005:( 3993:) 3985:( 3956:) 3952:( 3940:) 3932:( 3881:, 3866:, 3854:J 3837:) 3730:) 3716:) 3703:) 3685:) 3640:f 3629:f 3618:f 3596:) 3581:) 3569:) 3556:) 3524:) 3399:) 3382:) 3347:) 3330:) 3293:) 3276:) 3239:( 3230:) 3226:( 3208:( 3199:) 3191:( 3182:D 3159:) 3147:) 3131:) 3087:) 3059:) 3013:) 2999:) 2953:) 2940:) 2927:) 2910:) 2878:) 2854:( 2822:( 2817:) 2805:) 2791:( 2786:) 2772:( 2709:) 2687:) 2635:) 2621:) 2608:) 2590:) 2556:/ 2534:, 2530:/ 2519:, 2470:) 2461:( 2458:) 2455:x 2449:x 2446:a 2443:\ 2440:( 2434:= 2428:) 2419:( 2416:) 2413:x 2407:r 2404:x 2401:\ 2398:( 2392:= 2358:] 2349:x 2346:| 2337:= 2328:] 2319:x 2316:| 2307:= 2283:] 2277:x 2274:| 2265:= 2262:n 2223:) 2220:g 2214:( 2211:g 2208:= 2205:g 2193:p 2190:\ 2187:( 2181:. 2178:) 2166:: 2163:x 2154:) 2148:: 2145:x 2142:( 2139:\ 2136:( 2130:. 2124:. 2121:) 2118:: 2115:3 2106:: 2103:2 2100:= 2072:) 2063:( 2057:) 2048:y 2045:x 2042:\ 2039:( 2030:λ 2024:) 2015:( 2009:) 2000:y 1997:x 1994:\ 1991:( 1982:λ 1976:) 1967:( 1961:) 1952:y 1949:x 1946:\ 1943:( 1934:λ 1928:) 1919:( 1913:) 1904:y 1901:x 1898:\ 1895:( 1886:λ 1835:z 1826:) 1823:x 1820:f 1814:. 1811:k 1805:k 1802:x 1799:\ 1796:( 1784:z 1781:f 1772:z 1763:) 1760:x 1757:f 1754:. 1751:k 1745:x 1742:k 1739:\ 1736:( 1724:z 1721:f 1705:: 1702:( 1696:( 1690:. 1687:z 1684:) 1681:f 1675:( 1666:z 1663:f 1655:f 1650:1 1644:) 1641:2 1635:) 1632:3 1626:0 1614:0 1608:3 1605:( 1599:2 1596:( 1590:1 1580:) 1574:: 1571:x 1565:x 1559:\ 1556:( 1550:= 1538:) 1529:( 1526:) 1523:b 1517:b 1514:a 1511:\ 1508:( 1470:f 1466:f 1438:) 1429:( 1426:) 1423:a 1417:b 1414:a 1411:\ 1408:( 1390:f 1386:f 1356:f 1350:( 1347:f 1341:( 1338:x 1335:f 1332:= 1329:) 1323:: 1320:x 1317:( 1314:f 1308:x 1305:= 1302:f 1296:) 1290:f 1284:: 1281:y 1278:x 1275:f 1272:( 1269:f 1263:= 1260:) 1254:: 1251:y 1248:: 1245:x 1242:( 1239:f 1233:x 1230:= 1227:f 1221:) 1215:f 1209:( 1206:x 1203:f 1200:= 1197:) 1191:: 1188:x 1185:( 1182:f 1176:x 1173:= 1170:f 1164:) 1158:: 1155:y 1152:x 1149:f 1146:( 1143:f 1137:= 1134:) 1128:: 1125:y 1122:: 1119:x 1116:( 1113:f 1107:x 1104:= 1101:f 1078:f 1063:t 1060:= 1057:t 1054:_ 1048:t 1045:f 1039:: 1036:y 1033:x 1030:f 1027:= 1024:) 1021:t 1018:: 1015:y 1012:: 1009:x 1006:( 1003:f 991:f 985:( 982:z 979:f 973:( 970:x 967:f 964:= 961:) 955:: 952:x 949:( 946:z 943:f 937:z 934:= 931:z 928:f 922:) 916:f 910:( 907:z 904:f 898:= 892:z 889:f 883:z 880:x 877:f 874:= 871:z 868:f 862:z 859:= 856:z 853:f 832:) 826:z 823:f 817:( 814:x 811:f 808:= 805:) 799:: 796:x 793:( 790:z 787:f 781:z 778:= 775:z 772:f 766:b 757:b 751:) 748:b 742:b 736:a 733:( 714:) 711:x 708:z 705:f 702:( 699:f 693:= 690:) 684:: 681:x 678:( 675:z 672:f 666:z 663:= 660:z 657:f 651:b 642:b 636:) 633:b 627:a 621:b 618:( 555:z 551:f 512:f 508:f 481:f 472:f 464:f 352:) 349:f 346:. 343:) 340:: 331:= 328:f 183:) 177:( 172:) 168:( 164:. 150:. 20:)

Index

Accumulate (higher-order function)
functional programming
higher-order functions
analyze
recursive
recursively
function
node
data structure
hierarchy
unfolds
corecursively
terminal
catamorphism
anamorphism

cite
sources
improve this section
adding citations to reliable sources
removed
Learn how and when to remove this message
Lists
cons
node
Haskell


right and left fold of a list
Lisp

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.