openrat-cms

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

index.html (2176B)


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