yorick: Fix evaluation of empty vectors in steps 2 and 3
[jackhill/mal.git] / docs / index.html
CommitLineData
d953db84 1<!DOCTYPE html>
a9993e0a 2<!--
b0e8fd07 3Copyright (c) 2019 Joel Martin
a9993e0a
JM
4Copyright (c) 2012 Fogus, Jen Myers and Relevance Inc.
5All rights reserved. The use and distribution terms for this software
6are covered by the Eclipse Public License 1.0
7(http://opensource.org/licenses/eclipse-1.0.php) which can be found in
8the file COPYING the root of this distribution. By using this
9software in any fashion, you are agreeing to be bound by the terms of
10this license. You must not remove this notice, or any other, from
11this software.
12-->
13
31690700 14<html>
a9993e0a 15<head>
d953db84 16 <meta charset="UTF-8" />
b0e8fd07
JM
17 <link rel="stylesheet" type="text/css" href="web/base.css" />
18 <link rel="stylesheet" type="text/css" href="web/layout.css" />
19 <link rel="stylesheet" type="text/css" href="web/skeleton.css" />
20 <link rel="stylesheet" type="text/css" href="web/himera.css" />
21 <link rel="stylesheet" type="text/css" href="web/ansi.css" />
22 <link rel="stylesheet" type="text/css" href="web/console.css" />
a9993e0a
JM
23 <style type="text/css" media="screen">
24 </style>
127fcbe0 25 <title>Mal Web REPL</title>
a9993e0a
JM
26</head>
27<body>
28 <div class="container">
29 <h1 id="title"><a href="https://github.com/kanaka/mal"/>Mal</a></h1>
30
31 <h2>Mal Web REPL</h2>
31690700 32
a9993e0a
JM
33 <!--
34 <div id="editor-container" class="sixteen columns">
35 <div id="tiny-note" class="tiny-note"></div>
36 <textarea class="editor" id="editor">;; Develop your Mal program here.
37;; Ctrl+E/Cmd+E evaluates file in the REPL.</textarea>
38 </div>
39 -->
40
41 <div id="console-container" class="sixteen columns">
42 <div class="console" id="console"></div>
43 </div>
44 <div class="eight columns">
45 <!--
46 <h3><span style="cursor: pointer" class="doc-link" id="toggle-editor">Show file editor</span></h3>
47 -->
48 <h3><span style="cursor: pointer" class="doc-link">&nbsp;</span></h3>
49 </div>
50 <div class="eight columns">
51 <div class="source">
b0e8fd07 52 <a href="http://github.com/kanaka/mal">View source on Github <img src="web/github-icon.png" /></a></p>
a9993e0a
JM
53 </div><!-- /source -->
54 </div>
55
56 <div class="rule sixteen columns"></div>
31690700 57
a9993e0a
JM
58 <div class="sixteen columns">
59 <h3>Mal at a glance</h3>
60 </div>
61
62 <div class="cheat-box-container eight columns">
63 <div class="cheat-box">
64 <h4>Datatypes</h4>
65 <table>
66 <tr class="row-one">
67 <td class="row-label">Maps</td>
68 <td>{"key1" "val1", "key2" 123}</td>
69 </tr>
d953db84 70 <tr>
a9993e0a
JM
71 <td class="row-label">Lists</td>
72 <td>(1 2 3 "four")</td>
73 </tr>
d953db84 74 <tr class="row-one">
a9993e0a
JM
75 <td class="row-label">Vectors</td>
76 <td>[1 2 3 4 "a" "b" "c" 1 2]</td>
77 </tr>
78 <tr>
79 <td class="row-label">Scalars</td>
d953db84 80 <td>a-symbol, "a string", :a_keyword, 123, nil, true, false</td>
a9993e0a
JM
81 </tr>
82 </table>
83 </div><!-- /cheat-box -->
84 <div class="cheat-box">
85 <h4>Functions</h4>
86 <table>
87 <tr class="row-one">
88 <td class="row-label">Calling</td>
89 <td>(<span class="ebnf">&lt;function&gt;</span>
90 <span class="ebnf">&lt;args*&gt;</span>)</td>
91 </tr>
92 <tr>
93 <td class="row-label">Defining named functions</td>
94 <td>(def! <span class="ebnf">&lt;name&gt;</span>
95 (fn*
96 [<span class="ebnf">&lt;args*&gt;</span>]
d953db84 97 <span class="ebnf">&lt;action&gt;</span>))</td>
a9993e0a
JM
98 </tr>
99 <tr class="row-one">
100 <td class="row-label">Anonymous function</td>
d953db84 101 <td>(fn*
a9993e0a 102 [<span class="ebnf">&lt;args*&gt;</span>]
d953db84 103 <span class="ebnf">&lt;action&gt;</span>)</td>
a9993e0a
JM
104 </tr>
105 </table>
106 </div><!-- /cheat-box -->
107 <div class="cheat-box">
108 <h4>Useful Macros and Special Forms</h4>
109 <table>
110 <tr class="row-one">
111 <td class="row-label">Conditionals</td>
112 <td>if cond or</td>
113 </tr>
114 <!--
115 <tr>
116 <td class="row-label">Nesting, chaining, and Interop</td>
117 <td>-> ->> doto .. .</td>
118 </tr>
119 -->
120 <tr>
121 <td class="row-label">Multiple Actions (side-effects)</td>
122 <td>(do
123 <span class="ebnf">&lt;action*&gt;</span>...)</td>
124 </tr>
125 <tr class="row-one">
126 <td class="row-label">Defining things</td>
127 <td>def! defmacro! let*</td>
128 </tr>
d953db84
DM
129 <tr>
130 <td class="row-label">Quoting</td>
131 <td>' ` ~ ~@</td>
132 </tr>
133 <tr class="row-one">
134 <td class="row-label">Examining macros</td>
135 <td>macroexpand</td>
136 </tr>
a9993e0a
JM
137 </table>
138 </div>
139 </div><!-- /cheat-box-container -->
31690700 140
a9993e0a
JM
141 <div class="cheat-box-container eight columns">
142 <div class="cheat-box">
143 <h4>Useful Functions</h4>
144 <table>
145 <tr class="row-one">
146 <td class="row-label">Math</td>
147 <td>+ - * /</td>
148 </tr>
149 <tr>
150 <td class="row-label">Comparison/Boolean</td>
151 <td>= < > <= >= not</td>
152 </tr>
153 <tr class="row-one">
154 <td class="row-label">Predicates</td>
d953db84 155 <td>nil? true? false? symbol? keyword? string? list? vector? map? sequential?</td>
a9993e0a
JM
156 </tr>
157 <tr>
158 <td class="row-label">Data processing</td>
159 <td>map apply</td>
160 </tr>
161 <tr class="row-one">
162 <td class="row-label">Data create</td>
163 <td>list vector hash-map</td>
164 </tr>
165 <tr>
166 <td class="row-label">Data inspection</td>
167 <td>first rest get keys vals count get nth contains? empty?</td>
168 </tr>
169 <tr class="row-one">
170 <td class="row-label">Data manipulation</td>
171 <td>conj cons concat assoc dissoc</td>
172 </tr>
173 <tr>
174 <td class="row-label">Lists and Vectors</td>
d953db84 175 <td>first rest nth seq</td></td>
a9993e0a
JM
176 </tr>
177 <tr class="row-one">
178 <td class="row-label">Hash Maps</td>
179 <td>get keys vals contains?</td></td>
180 </tr>
d953db84
DM
181 <tr>
182 <td class="row-label">Strings</td>
183 <td>str pr-str seq</td></td>
184 </tr>
185 <tr class="row-one">
186 <td class="row-label">Atoms</td>
187 <td>atom atom? deref[@] reset! swap!</td></td>
188 </tr>
189 <tr>
190 <td class="row-label">Meta</td>
191 <td>meta with-meta[^]</td></td>
192 </tr>
193 <tr class="row-one">
194 <td class="row-label">Output</td>
195 <td>println prn</td></td>
196 </tr>
a9993e0a
JM
197 </table>
198 </div><!-- /cheat-box -->
199 <div class="cheat-box">
200 <h4>JavaScript Interop</h4>
201 <table>
202 <tr class="row-one">
203 <td class="row-label">Evaluate JavaScript</td>
d953db84 204 <td>(js-eval "JS string to eval")</td>
a9993e0a
JM
205 </tr>
206 <tr>
207 <td class="row-label">Method call/access</td>
208 <td>(. js-fn arg...)</td>
209 </tr>
210 </table>
211 </div>
212 </div><!-- /cheat-box-container -->
213
214 <div class="rule sixteen columns"></div>
215
216 <div class="column footer-logo">
b0e8fd07 217 <div>Mal &copy; 2019 Joel Martin</div>
a9993e0a
JM
218 <div>Himera design &copy; 2012-2013 <a ref="http://www.fogus.me">Fogus</a>, <a href="http://jenmyers.net/">Jen Myers</a> and <a href="http://www.thinkrelevance.com">Relevance Inc.</a></div>
219 </div>
220
221 </div><!-- / container -->
fc5c2c6f 222 <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
b0e8fd07
JM
223 <script type="text/javascript" src="web/jqconsole.min.js"></script>
224 <script type="text/javascript" src="web/mal.js"></script>
a9993e0a
JM
225 <script>
226 $(function() {
227 // Creating the console.
228 window.jqconsole = $('#console').jqconsole(null, 'user> ');
229
230 printer.println = function () {
231 var str = Array.prototype.join.call(arguments, " ")
232 jqconsole.Write(str + "\n", 'jqconsole-output');
233 }
234
235 rep("(println (str \"Mal [\" *host-language* \"]\"))");
236
b58698b2
JM
237 jq_load_history(jqconsole);
238
a9993e0a
JM
239 // Abort prompt on Ctrl+C.
240 jqconsole.RegisterShortcut('C', function() {
241 jqconsole.AbortPrompt();
242 handler();
243 });
244 // Move to line start Ctrl+A.
245 jqconsole.RegisterShortcut('A', function() {
246 jqconsole.MoveToStart();
247 handler();
248 });
249 // Move to line end Ctrl+E.
250 jqconsole.RegisterShortcut('E', function() {
251 jqconsole.MoveToEnd();
252 handler();
253 });
254 jqconsole.RegisterMatching('{', '}', 'brace');
255 jqconsole.RegisterMatching('(', ')', 'paren');
256 jqconsole.RegisterMatching('[', ']', 'bracket');
257 jqconsole.RegisterMatching('"', '"', 'dquote');
258 // Handle a command.
259 var handler = function(line) {
260 if (line) {
261 try {
262 jqconsole.Write(rep(line) + '\n', 'jqconsole-return');
263 } catch (exc) {
264 if (exc instanceof reader.BlankException) { return; }
265 if (exc.stack) {
266 jqconsole.Write(exc.stack + '\n', 'jqconsole-error');
267 } else {
268 jqconsole.Write(exc + '\n', 'jqconsole-error');
e4393504
JM
269 }
270 }
b58698b2 271 jq_save_history(jqconsole);
a9993e0a
JM
272 }
273 jqconsole.Prompt(true, handler);
274 /*
275 jqconsole.Prompt(true, handler, function(command) {
276 // Continue line if can't compile the command.
277 try {
278 Function(command);
279 } catch (e) {
280 if (/[\[\{\(]$/.test(command)) {
281 return 1;
282 } else {
283 return 0;
e4393504 284 }
a9993e0a
JM
285 }
286 return false;
287 });
288 */
289 };
31690700 290
a9993e0a
JM
291 // Initiate the first prompt.
292 handler();
293 });
294 </script>
295
296</body>
31690700 297</html>