aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-25 22:16:23 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-25 22:16:23 -0500
commit59bbbbf0b2702906cdd1b08429b9712b7c77d39a (patch)
treedf96ad39d44a44ef1411358ff5d2b1b43f837d79 /doc
parent92fad6dd8d642dc131106db707080a5cd764e2f7 (diff)
Translate some J modifiers
Diffstat (limited to 'doc')
-rw-r--r--doc/fromJ.md29
1 files changed, 25 insertions, 4 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↓↓` |