fold
Practical use of fold/reduce in functional languages
Fold (aka reduce) is considered a very important higher order function. Map can be expressed in开发者_运维百科 terms of fold (see here). But it sounds more academical than practical to me. A typical u[详细]
2023-02-17 12:08 分类:问答Why doesn't Option have a fold method?
I wonder wh开发者_StackOverflow社区y scala.Option doesn\'t have a method fold like this defined:[详细]
2023-02-17 09:37 分类:问答Recursion over lists in Haskell
For instance, i have a list like [\'a\',\'b\',\'c\',\'d\',\'e\']. I want to do something like this: First do something with the firs开发者_Python百科t two elements, f \'a\' \'b\'[详细]
2023-02-17 02:13 分类:问答Erlang: is it possible to write the minimum function as a list fold?
Given a function: 开发者_运维技巧min(A, B)when A =< B -> A; min(_A, B)-> B. can I use this in the function foldlin a similar fashion to this:[详细]
2023-02-14 20:57 分类:问答An alternate to foldLeft that starts from second element
I have a List defined as: val l = List(\"1\", \"2\", \"3\") I want to convert it to the string \"1:2:3\"[详细]
2023-02-14 01:41 分类:问答Generalized foldr and foldl for using with generic Haskell trees?
How can I write general开发者_如何学Cized foldr and foldl function for generic Haskell trees, given this definition?[详细]
2023-02-10 11:38 分类:问答How can I check if a BST is valid?
How can I check if a BST is a valid one, given its definition and using a generalized version of fold for BST?[详细]
2023-02-09 23:29 分类:问答Why foldl1 fails applying the (==) operator?
From prelude: foldl1: it takes the first 2 items of the list and applies the function to them, then 开发者_开发技巧feeds the function with[详细]
2023-02-09 07:10 分类:问答Recursive bottom-up traversal of algebraic data types
When dealing with sizeable algebraic data types in Haskell, there is a particular recursive traversal not captured by folding over the data type. For instance, suppose I have a simple data type repres[详细]
2023-02-08 12:34 分类:问答Optimisations with folds
I am just curious if there are any (first order polymorphic only) optimisations with folds. For maps, there\'s deforestation开发者_运维知识库: map g (map f ls) => map (g . f) ls, and rev (map f ls[详细]
2023-02-07 12:27 分类:问答