APL mode

x
 
1
⍝ Conway's game of life
2
3
⍝ This example was inspired by the impressive demo at
4
⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
5
6
⍝ Create a matrix:
7
⍝     0 1 1
8
⍝     1 1 0
9
⍝     0 1 0
10
creature  (3 3   9)  1 2 3 4 7   ⍝ Original creature from demo
11
creature  (3 3   9)  1 3 6 7 8   ⍝ Glider
12
13
⍝ Place the creature on a larger board, near the centre
14
board  ¯1  ¯2  5 7  creature
15
16
⍝ A function to move from one generation to the next
17
life  {/ 1   3 4 = +/ + 1 0 ¯1 ∘. 1 0 ¯1 ¨ }
18
19
⍝ Compute n-th generation and format it as a
20
⍝ character matrix
21
gen  {' #'[(life  ) board]}
22
23
⍝ Show first three generations
24
(gen 1) (gen 2) (gen 3)
25

Simple mode that tries to handle APL as well as it can.

It attempts to label functions/operators based upon monadic/dyadic usage (but this is far from fully fleshed out). This means there are meaningful classnames so hover states can have popups etc.

MIME types defined: text/apl (APL code)