index.html 2.1 KB

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