From 59bbbbf0b2702906cdd1b08429b9712b7c77d39a Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 25 Jan 2021 22:16:23 -0500 Subject: Translate some J modifiers --- doc/fromJ.md | 29 +++++++++++++++--- docs/doc/fromJ.html | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 112 insertions(+), 5 deletions(-) diff --git a/doc/fromJ.md b/doc/fromJ.md index 53565405..c7d7c153 100644 --- a/doc/fromJ.md +++ b/doc/fromJ.md @@ -74,9 +74,9 @@ Functions `+` `-` `|` `<` `>` are the same in both languages. Most of BQN's combinators have J equivalents. The J equivalent `"_` for `˙` assumes a noun operand, but `˙` makes a constant function for any operand. `◶` has arguments reversed relative to `@.`, and uses an actual array of functions rather than gerunds. Besides these, BQN's `⟜` is like a J hook, that is, `F⟜G` is `(F G)`, and `⊸` applies in the opposite direction. -| BQN | `˙` | `˜` | `∘` | `○` | `⌾` | `⊘` | `◶` | -|:---:|:----:|:---:|:----:|:----:|:-----:|:---:|:----:| -| J | `"_` | `~` | `@:` | `&:` | `&.:` | `:` | `@.` | +| BQN | `˙` | `˜` | `∘` | `○` | `⌾` | `⊘` | `◶` | `⎊` | +|:---:|:----:|:---:|:----:|:----:|:-----:|:---:|:----:|:----:| +| J | `"_` | `~` | `@:` | `&:` | `&.:` | `:` | `@.` | `::` | For other modifiers the correspondence is looser. Here `⌜` shows the dyadic case and `´` the monadic case only. @@ -101,6 +101,10 @@ Some other primitives are essentially the same in J and BQN, but with different |:---:|:---:|:---:|:---:|:----:|:----:|:----:|:----:|:---:|:---:|:-----:|:-----:| | BQN | `×` | `÷` | `⋆` | `⋆⁼` | `√` | `⌊` | `⌈` | `⊣` | `⊢` | `⌽` | `⍉` | +| J | `~` | `@:` | `&:` | `&.:` | `:` | `/` | `"` | `L:` | `^:` | +|:---:|:---:|:----:|:----:|:-----:|:---:|:---:|:---:|:----:|:----:| +| BQN | `˜` | `∘` | `○` | `⌾` | `⊘` | `˝` | `⎉` | `⚇` | `⍟` | + Additionally, `|.!.f` is `⥊⟜f⊸«` with a natural number left argument. Change `«` to `»` to rotate right instead of left. The tables below give approximate implementations of J primitives. J has a whole lot of complicated primitives that no one uses (some of which are officially deprecated), so not everything is translated here. @@ -137,7 +141,24 @@ The tables below give approximate implementations of J primitives. J has a whole | `}:` | `¯1⊸↓` | | `e.` | `><∘∾∊¨⊢` | `∊` | `E.` | | `⍷` -| `i.` | `↕` | `⊐` +| `i.` | `↕` (`⥊⟜(↕×´)` for lists) | `⊐` | `i:` | `{𝕩-˜↕1+2×𝕩}` | `≠∘⊣-1+⌽⊸⊐` | `I.` | `/` | `⍋` | `L.` | `≡` | + +Some J modifier expressions are translated below. BQN doesn't keep track of the rank of functions, so the "close" compositions `@` `&` `&.` have no BQN equivalents: instead, specify a rank after composing. + +| J | BQN +|----------------|----- +| `&.>` | `¨` +| `` F`G`H@.C `` | `C◶⟨F,G,H⟩` +| `x y} z` | `x⌾(y⊸⊏) z` +| `F/ .G` | `F˝∘G⎉1‿∞` (dyadic) + +BQN uses functions, not modifiers, for structural manipulation. The following table gives BQN functions corresponding to J's structural modifiers. The result is an array of arrays; use `F¨` to apply a function to each of these, and `>F¨` to apply a function and merge the results into a single array. + +| J | Monad | Dyad +|------|---------------|------ +| `/.` | `(+⌜´↕¨∘≢)⊸⊔` | `⊐⊸⊔` +| `\` | `1↓↑` | `<˘↕` +| `\.` | `¯1↓↓` | diff --git a/docs/doc/fromJ.html b/docs/doc/fromJ.html index 72d4f59b..432bf72f 100644 --- a/docs/doc/fromJ.html +++ b/docs/doc/fromJ.html @@ -279,6 +279,7 @@ + @@ -291,6 +292,7 @@ &.: : @. +:: @@ -383,6 +385,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
J~@:&:&.::/"L:^:
BQN˜˝

Additionally, |.!.f is f« with a natural number left argument. Change « to » to rotate right instead of left.

The tables below give approximate implementations of J primitives. J has a whole lot of complicated primitives that no one uses (some of which are officially deprecated), so not everything is translated here.

@@ -546,7 +578,7 @@ - + @@ -566,3 +598,57 @@
i. ((↕×´) for lists)
+

Some J modifier expressions are translated below. BQN doesn't keep track of the rank of functions, so the "close" compositions @ & &. have no BQN equivalents: instead, specify a rank after composing.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
JBQN
&.>¨
F`G`H@.CCF,G,H
x y} zx(y) z
F/ .GF˝G1 (dyadic)
+

BQN uses functions, not modifiers, for structural manipulation. The following table gives BQN functions corresponding to J's structural modifiers. The result is an array of arrays; use F¨ to apply a function to each of these, and >F¨ to apply a function and merge the results into a single array.

+ + + + + + + + + + + + + + + + + + + + + + + + + +
JMonadDyad
/.(+⌜´¨)
\1↓↑<˘
\.¯1↓↓
-- cgit v1.2.3