Search notes:

Common first class function: fold

There are two versions of the fold operator: a right-fold and a left-fold. The fold operator takes as its arguments a so called zero-value (Z), a function (f) and a list.
f takes as its arguments two values and returns one value.
Fold-right:
fold_right(Z, f, [v1, v2, v3]) == f(v1, f(v2, f(v3, Z)))
Fold-left:
fold_left(Z, f, [v1, v2, v3]) == f(f(f(Z, v1), v2), v3)

Misc

The fold operator has its origins in recursion theory (Kleene, 1952).

See also

Functional programming

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/science/...', 1758206305, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/science/computer/Programming-paradigm/Functional-programming/First-class-function/fold(52): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78