Posts tagged with J

## High-dimensional Arrays in J

`J` is hott. Some highlights from the Wikipedia article and `J`'s homepage:

• you can do a lot with just a few characters in `J`. Define a moving average in 8 characters, including spaces, for example.
• Have you ever felt like whether it’s Java or C, Python or Ruby, all these languages are just the Same Old Thing?

`J` makes thinking in high-dimensional arrays easy.

1. The sentence `.i 7 8` means “Show me a `7×8` two-array” (ok, “matrix” but … matrices are verbs and arrays are nouns)
2. The sentence `.i 7 8 3` means “Show me a 7×8×3 three-array”.
3. The sentence `.i 7 8 3 4 13 2 66 means "Show me a 7×8×3×4×13×2×66` dimensional seven-array”.

I won’t reprint the long outputs but here’s a shorter one.

```   i.4 5 3
0  1  2
3  4  5
6  7  8
9 10 11
12 13 14

15 16 17
18 19 20
21 22 23
24 25 26
27 28 29

30 31 32
33 34 35
36 37 38
39 40 41
42 43 44

45 46 47
48 49 50
51 52 53
54 55 56
57 58 59
```

And another for clarity:

```   i.3 5 4
0  1  2  3
4  5  6  7
8  9 10 11
12 13 14 15
16 17 18 19

20 21 22 23
24 25 26 27
28 29 30 31
32 33 34 35
36 37 38 39

40 41 42 43
44 45 46 47
48 49 50 51
52 53 54 55
56 57 58 59```

This is reminiscent of using `R`'s `combn` function to visualise higher-dimensional stuff, right?

I guess this is how computers think all the time! I wonder what they say about us when we’re not around.

Things that are easy in `J` but hard in other languages:

• generating a bunch of crazy surfaces
• computing Gaussian curvatures of areas and geodesic curvatures of (closed) boundary curves
• checking the Gauß-Bonnet Theorem

(Source: jsoftware.com)