From aaac31f1668fe5516902ee7d2034e5c0e41667a6 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 13 Jul 2022 16:37:06 -0400 Subject: Support line breaks inside brackets in markdown BQN evaluation --- docs/doc/functional.html | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'docs/doc/functional.html') diff --git a/docs/doc/functional.html b/docs/doc/functional.html index ea4d18ca..f3eea496 100644 --- a/docs/doc/functional.html +++ b/docs/doc/functional.html @@ -70,14 +70,13 @@

What does functional programming in BQN look like? How is it different from the typical APL style of manipulating functions with operators?

Working with roles

First, let's look at the basics: a small program that has functions as its argument and result. The function Lin below gives a linear approximation to its function argument based on the values at 0 and 1. To find these two values, we call the argument as a function by using its uppercase spelling, 𝕏.

-
Lin  {
-  v0  𝕏 0
-  v0 + ((𝕏 1) - v0) × 
-}
+↗️
    Lin  {
+      v0  𝕏 0
+      v0 + ((𝕏 1) - v0) × 
+    }
 

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 (we'll discuss only tacit functions here; for blocks see lexical scoping).

-↗️
    Lin  { v0𝕏0  v0+((𝕏1)-v0)×⊢ }  # (copy of above)
-    Exp  
+↗️
    Exp  
     Lin exp
 1+1.718281828459045×⊢
 
@@ -95,14 +94,13 @@ 148.4131591025766

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 𝔽.

-
_lin  {
-  v0  𝔽 0
-  v0 + ((𝔽 1) - v0) × 
-}
+↗️
    _lin  {
+      v0  𝔽 0
+      v0 + ((𝔽 1) - v0) × 
+    }
 

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)×⊢ }  # (copy again)
-    Exp _lin 5
+↗️
    Exp _lin 5
 9.591409142295225
 

Arrays of functions

-- cgit v1.2.3