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/index.html | 1 + docs/doc/primitive.html | 2 +- docs/doc/valences.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 docs/doc/valences.html (limited to 'docs/doc') diff --git a/docs/doc/index.html b/docs/doc/index.html index 5d303de3..c3d6ea2b 100644 --- a/docs/doc/index.html +++ b/docs/doc/index.html @@ -77,6 +77,7 @@
  • Take and Drop ()
  • Transpose ()
  • Undo ()
  • +
  • Valences ()
  • Windows ()
  • Environment:

    diff --git a/docs/doc/primitive.html b/docs/doc/primitive.html index 1601ed08..44a0e14b 100644 --- a/docs/doc/primitive.html +++ b/docs/doc/primitive.html @@ -467,7 +467,7 @@ -Valences +Valences {𝔽𝕩;𝕨𝔾𝕩} Apply 𝔽 if there's one argument but 𝔾 if there are two 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 𝕨01𝕩 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).

    +↗️
            {𝕨01𝕩} 'x'
    +0
    +
    +    'w' {𝕨01𝕩} 'x'
    +1
    +
    -- cgit v1.2.3