Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  1. Curry & Fold - what are the etymologies in the programmatic sense? I do not see how any of the English meanings of these homonyms is related to the functionality of these terms.

  2. If you had to rename them to something more obvious - how would you do it?

like image 603
rapt Avatar asked Dec 19 '22 21:12

rapt


1 Answers

Curry is the last name of Haskell Curry, a prominent 20th century logician after whom Haskell got its name.

And "folding" simply because the fold operator figuratively represents folding, like a hand of cards can be folded to look like a single card. Think of foldr (+) 0 [1,2,3] == 6 as a hand of cards 1, 2 and 3 folded into a single card 6.

The word "reducing", which also means folding, can be illustrated using a similar analogy.

Of course, Haskell is more magic than even the bluffiest and luckiest game of poker, so folds in functional programming can actually produce a deck of cards that holds more cards than the hand it was folded from, or cards can be folded into cats, etc: foldr (\i, acc -> [show i,show i,show i] ++ acc) [] [1,2,3] == ["1","1","1","2","2","2","3","3","3"]. Therefore what started out as folding eventually evolved into an extremely universal operator that can produce map as well as filter etc, so don't get too carried away with the poker comparison and etymology.


As to what to name them to: renaming a dead person might not be the most ethical thing to do. The poor guy is so successful BOTH of his names are used for big things, and then you want to deprive him posthumously of his joy and rename him to something else? Unless perhaps that something else is Newton Watt Scoville or Kelvin Celsius Ângström, I'd seriously not attempt a rename.

However if you meant renaming the programming concept: it could instead be referred to by the name "ricing" in my hungry opinion. But Mr. Curry might still feel intimidated.

Folding could actually be renamed to bluffing, if you're not fulfilled by the multitude of presently available names for it — thanks to som-snytt for the constructive idea.

like image 190
Erik Kaplun Avatar answered Mar 25 '23 03:03

Erik Kaplun