This is a collection of idioms and small programs in APL, J, BQN, Julia, R, NumPy, Nial, Futhark & SaC.
There are several sites that do these kinds of comparisons:
General | Array Language Specific | Array Library Specific |
---|---|---|
Rosetta Code | BQN-Dyalog Dictionary | ArrayFire-MATLAB-NumPy |
Programming-Idioms | BQN-Dyalog Dictionary | ArrayFire-Eigen |
J-Dyalog APL Rosetta | ArrayFire-Numpy | |
Q-APL Dictionary | MatX-MATALB-NumPy |
Language | π² | Main Website | Help / Docs | Online REPL | |
---|---|---|---|---|---|
π | Dyalog APL | dyalog.com | Dyalog Help | TryAPL | |
π | Kap | kapdemo.dhsdevelopments.com | Kap Ref | Kap Interpreter | |
π | J | jsoftware.com | J NuVoc | J Playground | |
π | BQN | mlochbaum.github.io/BQN | BQN Docs | BQNPAD | |
π | Uiua | uiua.org | Uiua Docs | UiuaPAD | |
π | Q | π² | code.kx.com/q | Q Ref | π« |
π | Julia | julialang.org | Julia Docs | Replit | |
π | MATLAB | π² | mathworks.com/products/matlab.html | MATLAB Help | π² |
π | NumPy* | numpy.org | NumPy Docs | Replit | |
π | R | r-project.org | R Docs | JDoodle | |
π | Nial | nial-array-language.org | Nial Dictionary | TIO | |
π | Futhark | futhark-lang.org | Futhark Docs | π« | |
π | Dex | github.com/google-research/dex-lang | InDex | π« | |
π | Ivy | pkg.go.dev/robpike.io/ivy | Ivy Docs | π« | |
ππ | SaC | sac-home.org | SaC Docs | π« | |
π | ArrayFire* | arrayfire.com | ArrayFire Docs | π« | |
π | MatX* | nvidia.github.io/MatX | MatX API Ref | π« | |
π | ATen* | - | ATen Docs | π« | |
π | Eigen* | eigen.tuxfamily.org | Eigen Dox | Godbolt |
* Library, not an actual language
- π Main (APL-Family) Array Languages
- π Fringe (APL-Family) Array Languages
- π Main (Non-APL-Family) Array Languages
- π Fringe / Research Array Languages
- π Array Compiler Backends / Array Libraries
- REPL
- Index Base
- Axis/Rank Model
LA
= Leading AxisTA
= Trailing AxisAA
= Axis Agnostic
- Application Model
()
= ParenthesesLR
= Left to RightRL
= Right to Left
- Row-major or Column-Major
1 | 2 | 3 | 4 | 5 | |
---|---|---|---|---|---|
APL | π | 1 (or βIO ) |
LA /TA |
RL |
Row |
Kap | π | 0 | LA /TA |
RL |
Row |
J | π | 0 | LA |
RL |
Row |
BQN | π | 0 | LA |
RL |
Row |
Uiua | π | 0 | LA |
RL |
Row |
Q | π | 0 | π« | RL |
Row |
Julia | π | 1 | AA |
() |
Column |
MATLAB | π | 1 | LA |
() |
Column |
NumPy | π | 0 | AA |
() |
Row |
R | π | 1 | AA |
() |
Column |
Nial | π | 1 | AA |
LR |
Row |
Futhark | π | 0 | π« | LR |
Row |
Dex | π | 0 | () |
||
Ivy | π | 1 (or origin ) |
π« | RL |
Row |
SaC | π« | 0 | LA |
() |
Row |
ArrayFire | π« | 0 | LA |
() |
Column |
MatX | π« | 0 | LA |
() |
Row |
- Length of Array (Leading Axis)
- Shape of Array
- Rank of Array
- Number of Elements in Array
6 | 7 | 8 | 9 | |
---|---|---|---|---|
APL | β’ |
β΄ |
β΄β΄ |
Γ/β΄ |
Kap | β’ |
β΄ |
β΄β΄ |
Γ/β΄ |
J | # |
$ |
$$ |
*/@$ |
BQN | β |
β’ |
β’β’ |
ΓΒ΄β’ |
Uiua | ⧻ |
β³ |
⧻Ⳡ|
⧻β |
Q | count |
π« | π« | count raze |
Julia | size(a, 1) |
size(a) |
ndims(a) |
length(a) |
MATLAB | length(a) |
size(a) |
rank(a) |
numel(a) |
NumPy | len(a) |
a.shape |
np.ndim(a) |
a.size |
R | dim(a)[1] |
dim(a) |
length(dim(a)) |
length(a) |
Nial | first shape |
shape |
valence |
tally |
Futhark | length |
π« | π« | flatten |> length |
Dex | size * |
π« | π« | |
Ivy | 1 take rho |
rho |
rho rho |
rho , |
SaC | shape(a)[0] |
shape(a) |
shape(shape(a)) |
prod(shape(a)) |
ArrayFire | a.dims()[0] |
a.dims() * |
a.numdims() * |
a.elements() |
MatX | a.Shape()[0] |
a.Shape() |
a.Rank() |
TotalSize(a) |
π Means the REPL has certain limitations
- Q REPL has no HOME, END, or any arrows (CTRL or not)
- Nial REPL has no CTRL left or right arrow
- Futhark REPL has no HOME, END, or DEL
- Dex REPL as no UP, DOWN and does not work with
rlwrap
If you are using Q, Nial, Futhark or other languages with REPL limitations, you can get around this by invoking with rlwrap
. On Linux using the Q REPL:
sudo apt install rlwrap
rlwrap taskset -c 2 ./q
Note that even when using rlwrap
, some of the limitations will remain (such as CTRL + arrows).
- Creating an Identity Matrix
- Creating an Iota Matrix
- Reversing a Matrix Row-wise, Column-wise and in Memory
- Summing a Matrix Row-wise, Column-wise and Down to a Scalar
# | Problem | πΉ | |
---|---|---|---|
1 | π | P0485 - MCO (Max Consecutive Ones) | - |
2 | π | P1351 - Count Negatives | YouTube Solution |
3 | π | P1614 - Maximum Nesting Depth of the Parentheses | YouTube Solution | II |
4 | π | P1672 - Richest Customer Wealth | YouTube Solution |
5 | π | P1822 - Sign of the Product of Array | YouTube Solution |
6 | π | P2319 - Check if Matrix Is X-Matrix | YouTube Solution |
7 | π | P0674 - LCIS (Longest Continuous Increasing Subsequence) | - |
8 | π | P00064 - Maixmum Gap | - |
9 | π | PWC198 P1 - Maximum Gap Count | - |
- π = All solutions complete
- π = Some solutions missing
Language | 1a | 1b | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
APL | π | π« | π | π | π | π | π | π | π | π |
Kap | π | π | π | π | π | π | π | π | π | π |
J | π | π | π | π | π | π | π | π | π | π |
BQN | π | π | π | π | π | π | π | π | π | π |
Uiua | π | π | π | π | π | π | π | π | π | π |
Q | π | π | π | π | π | π | π | π | π | π |
Julia | π« | π | π | π« | π | π | π | π | π | π |
MATLAB | π | π« | π | π« | π | π | π | π | π | π |
NumPy | π | π | π | π« | π | π | π | π | π | π |
R | π | π | π | π | π | π | π | π | π | π |
Nial | π | π« | π | π | π | π | π | π | π | π |
Futhark | π | π | π | π | π | π | π | π | π | π |
Dex | π« | π« | π | π« | π | π | π | π« | ||
Ivy | π« | π« | π | π | π | π | π | π | π | π |
SaC | π | π | π | π | π | π | π | π | π | π |
ArrayFire | π | π | π | π | π | π | π | π | π | π |
MatX | π | π | π | π | π | π | π | π | π | π |