1
0

index.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  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>
  11. <style>
  12. .CodeMirror { border: 2px inset #dee; }
  13. </style>
  14. </head>
  15. <body>
  16. <h1>CodeMirror: APL mode</h1>
  17. <form><textarea id="code" name="code">
  18. ⍝ Conway's game of life
  19. ⍝ This example was inspired by the impressive demo at
  20. ⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
  21. ⍝ Create a matrix:
  22. ⍝ 0 1 1
  23. ⍝ 1 1 0
  24. ⍝ 0 1 0
  25. creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
  26. creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
  27. ⍝ Place the creature on a larger board, near the centre
  28. board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
  29. ⍝ A function to move from one generation to the next
  30. life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
  31. ⍝ Compute n-th generation and format it as a
  32. ⍝ character matrix
  33. gen ← {' #'[(life ⍣ ⍵) board]}
  34. ⍝ Show first three generations
  35. (gen 1) (gen 2) (gen 3)
  36. </textarea></form>
  37. <script>
  38. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  39. lineNumbers: true,
  40. matchBrackets: true,
  41. mode: "text/apl"
  42. });
  43. </script>
  44. <p>Simple mode that tries to handle APL as well as it can.</p>
  45. <p>It attempts to label functions/operators based upon
  46. monadic/dyadic usage (but this is far from fully fleshed out).
  47. This means there are meaningful classnames so hover states can
  48. have popups etc.</p>
  49. <p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
  50. </body>
  51. </html>