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 --- doc/README.md | 1 + doc/combinator.bqn | 2 +- doc/primitive.md | 2 +- doc/valences.md | 19 +++++++++++++++++++ docs/doc/index.html | 1 + docs/doc/primitive.html | 2 +- docs/doc/valences.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ docs/help/valences.html | 2 ++ help/valences.md | 2 ++ 9 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 doc/valences.md create mode 100644 docs/doc/valences.html diff --git a/doc/README.md b/doc/README.md index 26374f5c..8acd5740 100644 --- a/doc/README.md +++ b/doc/README.md @@ -71,6 +71,7 @@ Primitives: - [Take and Drop](take.md) (`↑`) - [Transpose](transpose.md) (`⍉`) - [Undo](undo.md) (`⁼`) +- [Valences](valences.md) (`⊘`) - [Windows](windows.md) (`↕`) Environment: diff --git a/doc/combinator.bqn b/doc/combinator.bqn index fa4466f7..e16dc5a9 100644 --- a/doc/combinator.bqn +++ b/doc/combinator.bqn @@ -4,7 +4,7 @@ w‿h ← 280‿260 Pnt ← 32‿57×⌽ comps ← "∘○˙⊸⟜˜⊘" -names ← (¬×+`)⊸-∘=⟜' '⊸⊔ "Atop Over Constant Before After Self/Swap Cases" +names ← (¬×+`)⊸-∘=⟜' '⊸⊔ "Atop Over Constant Before After Self/Swap Valences" ps ← At "class=yellow|style=fill:none|stroke-width=2" _trans ← {𝕗 At "transform=translate("∾(⊣∾","∾⊢)○FmtNum∾")"˙} diff --git a/doc/primitive.md b/doc/primitive.md index c358d80a..b1253e3c 100644 --- a/doc/primitive.md +++ b/doc/primitive.md @@ -74,7 +74,7 @@ Glyph | Name(s) | Definition | Description `⊸` | Before/Bind | `{(𝔽𝕨⊣𝕩)𝔾𝕩}` | `𝔾`'s left argument comes from `𝔽` `⟜` | After/Bind | `{(𝕨⊣𝕩)𝔽𝔾𝕩}` | `𝔽`'s right argument comes from `𝔾` `⌾` | Under | `{𝔾⁼∘𝔽○𝔾}` OR `{(𝔾𝕩)↩𝕨𝔽○𝔾𝕩⋄𝕩}` | Apply `𝔽` over `𝔾`, then undo `𝔾` -`⊘` | Valences | `{𝔽𝕩;𝕨𝔾𝕩}` | Apply `𝔽` if there's one argument but `𝔾` if there are two +`⊘` | [Valences](valences.md) | `{𝔽𝕩;𝕨𝔾𝕩}` | Apply `𝔽` if there's one argument but `𝔾` if there are two `◶` | Choose | `{f←(𝕨𝔽𝕩)⊑𝕘 ⋄ 𝕨F𝕩}` | Select one of the functions in list `𝕘` based on `𝔽` Choose isn't really a combinator since it calls the function `⊑`, and Under is not a true combinator since it has an "undo" step at the end. This step might be implemented using the left operand's inverse (*computational* Under) or its structural properties (*structural* Under). diff --git a/doc/valences.md b/doc/valences.md new file mode 100644 index 00000000..7c2c9d59 --- /dev/null +++ b/doc/valences.md @@ -0,0 +1,19 @@ +*View this file with results and syntax highlighting [here](https://mlochbaum.github.io/BQN/doc/valences.html).* + +# 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](tacit.md) equivalent of a block function with [two bodies](block.md#multiple-bodies). So the function `{÷𝕩 ; 𝕩-𝕨}` can also be written `÷⊘(-˜)`. A full definition of Valences as a block is `{𝔽𝕩;𝕨𝔾𝕩}`. + + -⊘+ 6 # - side + + 3 -⊘+ 2 # + side + +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' + + 'w' {𝕨0⊘1𝕩} 'x' 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
    +
    diff --git a/docs/help/valences.html b/docs/help/valences.html index 90848a48..2600623b 100644 --- a/docs/help/valences.html +++ b/docs/help/valences.html @@ -6,6 +6,7 @@

    Circled Division Slash ()

    𝔽𝔾 𝕩: Valences

    +

    →full documentation

    Apply 𝔽 to 𝕩.

    ↗️
        +- 5
     5
    @@ -14,6 +15,7 @@
     ¯5
     

    𝕨 𝔽𝔾 𝕩: Dyadic Valences

    +

    →full documentation

    Apply 𝔾 to 𝕨 and 𝕩.

    ↗️
        4 +- 5
     ¯1
    diff --git a/help/valences.md b/help/valences.md
    index 2a220848..f71c5bc3 100644
    --- a/help/valences.md
    +++ b/help/valences.md
    @@ -3,6 +3,7 @@
     # Circled Division Slash (`⊘`)
     
     ## `𝔽⊘𝔾 𝕩`: Valences
    +[→full documentation](../doc/valences.md)
     
     Apply `𝔽` to `𝕩`.
     
    @@ -13,6 +14,7 @@ Apply `𝔽` to `𝕩`.
     
     
     ## `𝕨 𝔽⊘𝔾 𝕩`: Dyadic Valences
    +[→full documentation](../doc/valences.md)
     
     Apply `𝔾` to `𝕨` and `𝕩`.
     
    -- 
    cgit v1.2.3