Functional programming: Curry & Fold - what are the etymologies?

  • Curry and Fold - What are the etymologies in a programmatic sense? I do not see how any of the English meanings of these homonyms is related to the functionality of these terms.

  • If you needed to rename them to something more obvious - how would you do it?

+4
source share
2 answers

I think the term “folds” comes mainly from the use of the word “fold” in phrases like “fold to ...” This is the term most often used by chefs, I think (I watch a lot of cooking shows ...) . We use it in the context of functional programming, because we say that, for example, for lists, the head of the list “collapses” as a result of folding the tail. For example, a function foldris a “recipe” for how to “cook” a list, and part of this recipe “folds it into this,” if you like.

"", , 1985 , :

"" . [...] .

, "" 30 !

+3

- , 20- Haskell .

"" , , , , . foldr (+) 0 [1,2,3] == 6 1, 2 3, 6.

"", , .

, Haskell , , , , , , ..: foldr (\i, acc -> [show i,show i,show i] ++ acc) [] [1,2,3] == ["1","1","1","2","2","2","3","3","3"]. , , , map, filter .., .


, : . , , ? , , - , .

, : "ricing" . .

Folding , - som- snytt .

+8

Source: https://habr.com/ru/post/1620453/


All Articles