diff options
Diffstat (limited to 'doc/functional.md')
| -rw-r--r-- | doc/functional.md | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/doc/functional.md b/doc/functional.md index 1d55e8b8..49fb0c25 100644 --- a/doc/functional.md +++ b/doc/functional.md @@ -109,25 +109,22 @@ First, let's look at the basics: a small program that has functions as its argum We can pass it the exponential function as an argument by giving it the name `Exp` and then referring to it in lowercase (that is, in a subject role). The result is a train that adds 1 to *e*-1 times the argument. + Lin โ { v0โ๐0 โ v0+((๐1)-v0)รโข } Exp โ โ Lin exp - (1 + (1.71828182845905 ร โข)) As with all functions, the result of `Lin` has a subject role. To use it as a function, we give it a name and then use that name with an uppercase spelling. expLin โ Lin exp ExpLin 5 - 9.59140914229523 A tricker but more compact method is to use the 1-modifier `{๐ฝ}`, as the input to a modifier can have a subject or function role but its output always has a function role. (Lin exp){๐ฝ} 5 - 9.59140914229523 Not the most accurate approximation, though. Exp 5 - 148.413159102577 Note also in this case that we could have used a modifier with a very similar definition to `Lin`. The modifier is identical in definition except that `๐` is replaced with `๐ฝ`. @@ -138,15 +135,14 @@ Note also in this case that we could have used a modifier with a very similar de Its call syntax is simpler as well. In other cases, however, the function version might be preferable, for example when dealing with arrays of functions or many arguments including a function. + _lin โฉ { v0โ๐ฝ0 โ v0+((๐ฝ1)-v0)รโข } Exp _lin 5 - 9.59140914229523 ### Arrays of functions It's very convenient to put a function in an array, which is fortunate because this is one of the most important uses of functions as subjects. Here's an example of an array of functions with a reduction applied to it, composing them together. {๐โ๐}ยด โโฟ-โฟ(รห) - โโ(-โ(รห)) Like any function, this one can be given a name and then called. A quirk of this way of defining a function is that it has a subject role (it's the result of the function `{๐โ๐}ยด`) and so must be defined with a lowercase name. |
