aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/wiki_src/coding/currying.md
diff options
context:
space:
mode:
authorMarvin Borner2023-11-06 18:50:35 +0100
committerMarvin Borner2023-11-06 18:50:35 +0100
commit1f7231153c172500f1073ddb22ec911379f83a07 (patch)
treef6914c30fcbeaf44c12b405eaa09065fb8203ac7 /docs/wiki_src/coding/currying.md
parent9d722a0b6138827de743f9fe4acbf3f2c1830bb0 (diff)
Improved wiki and reduced readme
Diffstat (limited to 'docs/wiki_src/coding/currying.md')
-rw-r--r--docs/wiki_src/coding/currying.md22
1 files changed, 19 insertions, 3 deletions
diff --git a/docs/wiki_src/coding/currying.md b/docs/wiki_src/coding/currying.md
index d84eb0a..9a8e48d 100644
--- a/docs/wiki_src/coding/currying.md
+++ b/docs/wiki_src/coding/currying.md
@@ -1,13 +1,29 @@
# Currying
-Lambda calculus naturally supports currying -- that is, only partially
+Lambda calculus naturally supports currying -- that is, only *partially*
applying a function. In fact *any* function can be applied with *any*
amount of arguments!
In bruijn, currying is a great way to make functions even more elegant.
-Partially applying the `mul`{.bruijn} function:
+For example, take the negation function:
``` bruijn
-six [0 (+3)] (mul (+2))
+# subtracts argument from zero
+-‣ [(+0) - 0] ⧗ Number → Number
+
+# equivalent curried version
+-‣ sub (+0)
+```
+
+Currying is also very useful for higher-order functions.
+
+Multiplying values in a list by partially applying the `mul`{.bruijn}
+function:
+
+``` bruijn
+# doubles numbers in a list
+double-list [0 <$> (mul (+2))] ⧗ (List Number) → (List Number)
+
+:test (double-list ((+1) : {}(+2))) ((+2) : {}(+4))
```