From 2528ec5e75daa358162619cc3a704e6bdf88a2c8 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 14 Apr 2022 21:45:05 -0400 Subject: Documentation for Valences --- docs/doc/valences.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 docs/doc/valences.html (limited to 'docs/doc/valences.html') diff --git a/docs/doc/valences.html b/docs/doc/valences.html new file mode 100644 index 00000000..90812056 --- /dev/null +++ b/docs/doc/valences.html @@ -0,0 +1,47 @@ + + + + BQN: Valences + + +

Valences

+ + + + Valences + + ๐”ฝโŠ˜๐”พ ๐•ฉ + + + + ๐”ฝ + ๐•ฉ + + + ๐•จ ๐”ฝโŠ˜๐”พ ๐•ฉ + + + + + + ๐”พ + ๐•จ + ๐•ฉ + + + + +

Every BQN function can be called with one or two arguments, possibly doing completely different things in each case. The Valences (โŠ˜) 2-modifier grafts together a one-argument function ๐”ฝ and a two-argument function ๐”พ, with the resulting function calling one or the other as appropriate. It's the tacit equivalent of a block function with two bodies. So the function {รท๐•ฉ ; ๐•ฉ-๐•จ} can also be written รทโŠ˜(-หœ). A full definition of Valences as a block is {๐”ฝ๐•ฉ;๐•จ๐”พ๐•ฉ}.

+โ†—๏ธ
      -โŠ˜+ 6  # - side
+ยฏ6
+
+    3 -โŠ˜+ 2  # + side
+5
+
+

Valences provides one way to check whether ๐•จ is present in a block function. The expression ๐•จ0โŠ˜1๐•ฉ always ignores the values of the arguments, resulting in 0 if ๐•จ isn't given and 1 if it is (if you want 1 or 2, then โ‰ ๐•จโ‹ˆ๐•ฉ is shorter, but I'm not sure if I like it).

+โ†—๏ธ
        {๐•จ0โŠ˜1๐•ฉ} 'x'
+0
+
+    'w' {๐•จ0โŠ˜1๐•ฉ} 'x'
+1
+
-- cgit v1.2.3