From b18960ec68ae64568ceab52047983bf77b74d166 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 1 Sep 2020 18:43:16 -0400 Subject: Generate some results in functional.md (still can't use multi-line defs or format functions) --- docs/doc/functional.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'docs') diff --git a/docs/doc/functional.html b/docs/doc/functional.html index 5e281743..04205144 100644 --- a/docs/doc/functional.html +++ b/docs/doc/functional.html @@ -58,22 +58,22 @@ (-(ט))

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
+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
-[ 3 [ 2 9 ] ¯8094.083927575384 ]
+↗️
    , 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"
-c
+↗️
    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
-[ 3 22 ]
+↗️
    (2|)÷2,1+3×⊢¨ 67
+⟨ 3 22 ⟩
     (2|)÷2,1+3×⊢(10) 6
-[ 6 3 10 5 16 8 4 2 1 4 ]
+⟨ 6 3 10 5 16 8 4 2 1 4 ⟩
 
-- cgit v1.2.3