5 <title>CodeMirror: APL mode</title>
6 <link rel="stylesheet" href="../../doc/docs.css">
7 <link rel="stylesheet" href="../../lib/codemirror.css">
8 <script src="../../lib/codemirror.js"></script>
9 <script src="../../addon/edit/matchbrackets.js"></script>
10 <script src="./apl.js"></script>
12 .CodeMirror { border: 2px inset #dee; }
16 <h1>CodeMirror: APL mode</h1>
18 <form><textarea id="code" name="code">
19 ⍝ Conway's game of life
21 ⍝ This example was inspired by the impressive demo at
22 ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
28 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
29 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
31 ⍝ Place the creature on a larger board, near the centre
32 board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
34 ⍝ A function to move from one generation to the next
35 life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
37 ⍝ Compute n-th generation and format it as a
39 gen ← {' #'[(life ⍣ ⍵) board]}
41 ⍝ Show first three generations
42 (gen 1) (gen 2) (gen 3)
46 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
53 <p>Simple mode that tries to handle APL as well as it can.</p>
54 <p>It attempts to label functions/operators based upon
55 monadic/dyadic usage (but this is far from fully fleshed out).
56 This means there are meaningful classnames so hover states can
59 <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>