index.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!doctype html>
  2. <title>CodeMirror: yacas 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=yacas.js></script>
  9. <style type=text/css>
  10. .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
  11. </style>
  12. <div id=nav>
  13. <a href="https://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="#">yacas</a>
  22. </ul>
  23. </div>
  24. <article>
  25. <h2>yacas mode</h2>
  26. <textarea id="yacasCode">
  27. // example yacas code
  28. Graph(edges_IsList) <-- [
  29. Local(v, e, f, t);
  30. vertices := {};
  31. ForEach (e, edges) [
  32. If (IsList(e), e := Head(e));
  33. {f, t} := Tail(Listify(e));
  34. DestructiveAppend(vertices, f);
  35. DestructiveAppend(vertices, t);
  36. ];
  37. Graph(RemoveDuplicates(vertices), edges);
  38. ];
  39. 10 # IsGraph(Graph(vertices_IsList, edges_IsList)) <-- True;
  40. 20 # IsGraph(_x) <-- False;
  41. Edges(Graph(vertices_IsList, edges_IsList)) <-- edges;
  42. Vertices(Graph(vertices_IsList, edges_IsList)) <-- vertices;
  43. AdjacencyList(g_IsGraph) <-- [
  44. Local(l, vertices, edges, e, op, f, t);
  45. l := Association'Create();
  46. vertices := Vertices(g);
  47. ForEach (v, vertices)
  48. Association'Set(l, v, {});
  49. edges := Edges(g);
  50. ForEach(e, edges) [
  51. If (IsList(e), e := Head(e));
  52. {op, f, t} := Listify(e);
  53. DestructiveAppend(Association'Get(l, f), t);
  54. If (String(op) = "<->", DestructiveAppend(Association'Get(l, t), f));
  55. ];
  56. l;
  57. ];
  58. </textarea>
  59. <script>
  60. var yacasEditor = CodeMirror.fromTextArea(document.getElementById('yacasCode'), {
  61. mode: 'text/x-yacas',
  62. lineNumbers: true,
  63. matchBrackets: true
  64. });
  65. </script>
  66. <p><strong>MIME types defined:</strong> <code>text/x-yacas</code> (yacas).</p>
  67. </article>