From 1d6a9cf1441bd6d478977715d82031e77c20ce5c Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 26 Oct 2020 15:46:38 -0400 Subject: Don't include &run in documentation REPL links: it's no longer used --- docs/doc/functional.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/doc/functional.html') diff --git a/docs/doc/functional.html b/docs/doc/functional.html index dbbee78a..7debbe20 100644 --- a/docs/doc/functional.html +++ b/docs/doc/functional.html @@ -109,20 +109,20 @@ (-(ט))

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.

-↗️
    gauss  {𝕎𝕏}´ -(ט)
+↗️
    gauss  {𝕎𝕏}´ -(ט)
     Gauss 2
 0.0183156388887342
 

Another, and probably more common, use of arrays of functions is to apply several different functions to one or more arguments. Here we apply three different functions to the number 9:

-↗️
    , 2, ⊢-⋆ {𝕎𝕩}¨ 9
+↗️
    , 2, ⊢-⋆ {𝕎𝕩}¨ 9
 ⟨ 3 ⟨ 2 9 ⟩ ¯8094.08392757538 ⟩
 

The 2-modifier Choose () relies on arrays of functions to… function. It's very closely related to Pick , and in fact when the left operand and the elements of the right operand are all data there's no real difference: Choose returns the constant function 𝕗𝕘.

-↗️
    2"abcdef" "arg"
+↗️
    2"abcdef" "arg"
 'c'
 

When the operands contain functions, however, the potential of Choose as a ternary-or-more operator opens up. Here's a function for a step in the Collatz sequence, which halves an even input but multiplies an odd input by 3 and adds 1. To get the sequence for a number, we can apply the same function many times. It's an open problem whether the sequence always ends with the repetition 4, 2, 1, but it can take a surprisingly long time to get there—try 27 as an argument.

-↗️
    (2|)÷2,1+3×⊢¨ 67
+↗️
    (2|)÷2,1+3×⊢¨ 67
 ⟨ 3 22 ⟩
     (2|)÷2,1+3×⊢(10) 6
 ⟨ 6 3 10 5 16 8 4 2 1 4 ⟩
-- 
cgit v1.2.3