openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

index.html (2179B)


      1 <!doctype html>
      2 
      3 <title>CodeMirror: APL mode</title>
      4 <meta charset="utf-8"/>
      5 <link rel=stylesheet href="../../doc/docs.css">
      6 
      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>
     11 <style>
     12 	.CodeMirror { border: 2px inset #dee; }
     13     </style>
     14 <div id=nav>
     15   <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
     16 
     17   <ul>
     18     <li><a href="../../index.html">Home</a>
     19     <li><a href="../../doc/manual.html">Manual</a>
     20     <li><a href="https://github.com/codemirror/codemirror">Code</a>
     21   </ul>
     22   <ul>
     23     <li><a href="../index.html">Language modes</a>
     24     <li><a class=active href="#">APL</a>
     25   </ul>
     26 </div>
     27 
     28 <article>
     29 <h2>APL mode</h2>
     30 <form><textarea id="code" name="code">
     31 ⍝ Conway's game of life
     32 
     33 ⍝ This example was inspired by the impressive demo at
     34 ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
     35 
     36 ⍝ Create a matrix:
     37 ⍝     0 1 1
     38 ⍝     1 1 0
     39 ⍝     0 1 0
     40 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7   ⍝ Original creature from demo
     41 creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8   ⍝ Glider
     42 
     43 ⍝ Place the creature on a larger board, near the centre
     44 board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
     45 
     46 ⍝ A function to move from one generation to the next
     47 life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
     48 
     49 ⍝ Compute n-th generation and format it as a
     50 ⍝ character matrix
     51 gen ← {' #'[(life ⍣ ⍵) board]}
     52 
     53 ⍝ Show first three generations
     54 (gen 1) (gen 2) (gen 3)
     55 </textarea></form>
     56 
     57     <script>
     58       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
     59         lineNumbers: true,
     60         matchBrackets: true,
     61         mode: "text/apl"
     62       });
     63     </script>
     64 
     65     <p>Simple mode that tries to handle APL as well as it can.</p>
     66     <p>It attempts to label functions/operators based upon
     67     monadic/dyadic usage (but this is far from fully fleshed out).
     68     This means there are meaningful classnames so hover states can
     69     have popups etc.</p>
     70 
     71     <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
     72   </article>