3 Copyright (c) 2014 Joel Martin
4 Copyright (c) 2012 Fogus, Jen Myers and Relevance Inc.
5 All rights reserved. The use and distribution terms for this software
6 are covered by the Eclipse Public License 1.0
7 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in
8 the file COPYING the root of this distribution. By using this
9 software in any fashion, you are agreeing to be bound by the terms of
10 this license. You must not remove this notice, or any other, from
16 <meta charset=
"UTF-8" />
17 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/base.css" />
18 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/layout.css" />
19 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/skeleton.css" />
20 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/himera.css" />
21 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/ansi.css" />
22 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/console.css" />
23 <style type=
"text/css" media=
"screen">
25 <title>Mal Web REPL
</title>
28 <div class=
"container">
29 <h1 id=
"title"><a href=
"https://github.com/kanaka/mal"/>Mal
</a></h1>
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>
41 <div id=
"console-container" class=
"sixteen columns">
42 <div class=
"console" id=
"console"></div>
44 <div class=
"eight columns">
46 <h3><span style="cursor: pointer" class="doc-link" id="toggle-editor">Show file editor</span></h3>
48 <h3><span style=
"cursor: pointer" class=
"doc-link"> </span></h3>
50 <div class=
"eight columns">
52 <a href=
"http://github.com/kanaka/mal">View source on Github
<img src=
"js/web/github-icon.png" /></a></p>
53 </div><!-- /source -->
56 <div class=
"rule sixteen columns"></div>
58 <div class=
"sixteen columns">
59 <h3>Mal at a glance
</h3>
62 <div class=
"cheat-box-container eight columns">
63 <div class=
"cheat-box">
67 <td class=
"row-label">Maps
</td>
68 <td>{
"key1" "val1",
"key2" 123}
</td>
71 <td class=
"row-label">Lists
</td>
72 <td>(
1 2 3 "four")
</td>
75 <td class=
"row-label">Vectors
</td>
76 <td>[
1 2 3 4 "a" "b" "c" 1 2]
</td>
79 <td class=
"row-label">Scalars
</td>
80 <td>a-symbol,
"a string", :a_keyword,
123, nil, true, false
</td>
83 </div><!-- /cheat-box -->
84 <div class=
"cheat-box">
88 <td class=
"row-label">Calling
</td>
89 <td>(
<span class=
"ebnf"><function
></span>
90 <span class=
"ebnf"><args*
></span>)
</td>
93 <td class=
"row-label">Defining named functions
</td>
94 <td>(def!
<span class=
"ebnf"><name
></span>
96 [
<span class=
"ebnf"><args*
></span>]
97 <span class=
"ebnf"><action
></span>))
</td>
100 <td class=
"row-label">Anonymous function
</td>
102 [
<span class=
"ebnf"><args*
></span>]
103 <span class=
"ebnf"><action
></span>)
</td>
106 </div><!-- /cheat-box -->
107 <div class=
"cheat-box">
108 <h4>Useful Macros and Special Forms
</h4>
111 <td class=
"row-label">Conditionals
</td>
116 <td class="row-label">Nesting, chaining, and Interop</td>
117 <td>-> ->> doto .. .</td>
121 <td class=
"row-label">Multiple Actions (side-effects)
</td>
123 <span class=
"ebnf"><action*
></span>...)
</td>
126 <td class=
"row-label">Defining things
</td>
127 <td>def! defmacro! let*
</td>
130 <td class=
"row-label">Quoting
</td>
134 <td class=
"row-label">Examining macros
</td>
139 </div><!-- /cheat-box-container -->
141 <div class=
"cheat-box-container eight columns">
142 <div class=
"cheat-box">
143 <h4>Useful Functions
</h4>
146 <td class=
"row-label">Math
</td>
150 <td class=
"row-label">Comparison/Boolean
</td>
151 <td>= <
> <=
>= not
</td>
154 <td class=
"row-label">Predicates
</td>
155 <td>nil? true? false? symbol? keyword? string? list? vector? map? sequential?
</td>
158 <td class=
"row-label">Data processing
</td>
162 <td class=
"row-label">Data create
</td>
163 <td>list vector hash-map
</td>
166 <td class=
"row-label">Data inspection
</td>
167 <td>first rest get keys vals count get nth contains? empty?
</td>
170 <td class=
"row-label">Data manipulation
</td>
171 <td>conj cons concat assoc dissoc
</td>
174 <td class=
"row-label">Lists and Vectors
</td>
175 <td>first rest nth seq
</td></td>
178 <td class=
"row-label">Hash Maps
</td>
179 <td>get keys vals contains?
</td></td>
182 <td class=
"row-label">Strings
</td>
183 <td>str pr-str seq
</td></td>
186 <td class=
"row-label">Atoms
</td>
187 <td>atom atom? deref[@] reset! swap!
</td></td>
190 <td class=
"row-label">Meta
</td>
191 <td>meta with-meta[^]
</td></td>
194 <td class=
"row-label">Output
</td>
195 <td>println prn
</td></td>
198 </div><!-- /cheat-box -->
199 <div class=
"cheat-box">
200 <h4>JavaScript Interop
</h4>
203 <td class=
"row-label">Evaluate JavaScript
</td>
204 <td>(js-eval
"JS string to eval")
</td>
207 <td class=
"row-label">Method call/access
</td>
208 <td>(. js-fn arg...)
</td>
212 </div><!-- /cheat-box-container -->
214 <div class=
"rule sixteen columns"></div>
216 <div class=
"column footer-logo">
217 <div>Mal
© 2013 Joel Martin
</div>
218 <div>Himera design
© 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>
221 </div><!-- / container -->
222 <script type=
"text/javascript" src=
"//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
223 <script type=
"text/javascript" src=
"js/web/jqconsole.min.js"></script>
224 <script type=
"text/javascript" src=
"js/web/mal.js"></script>
227 // Creating the console.
228 window
.jqconsole
= $('#console').jqconsole(null, 'user> ');
230 printer
.println = function () {
231 var str
= Array
.prototype.join
.call(arguments
, " ")
232 jqconsole
.Write(str
+ "\n", 'jqconsole-output');
235 rep("(println (str \"Mal [\" *host-language* \"]\"))");
237 jq_load_history(jqconsole
);
239 // Abort prompt on Ctrl+C.
240 jqconsole
.RegisterShortcut('C', function() {
241 jqconsole
.AbortPrompt();
244 // Move to line start Ctrl+A.
245 jqconsole
.RegisterShortcut('A', function() {
246 jqconsole
.MoveToStart();
249 // Move to line end Ctrl+E.
250 jqconsole
.RegisterShortcut('E', function() {
251 jqconsole
.MoveToEnd();
254 jqconsole
.RegisterMatching('{', '}', 'brace');
255 jqconsole
.RegisterMatching('(', ')', 'paren');
256 jqconsole
.RegisterMatching('[', ']', 'bracket');
257 jqconsole
.RegisterMatching('"', '"', 'dquote');
259 var handler = function(line
) {
262 jqconsole
.Write(rep(line
) + '\n', 'jqconsole-return');
264 if (exc
instanceof reader
.BlankException
) { return; }
266 jqconsole
.Write(exc
.stack
+ '\n', 'jqconsole-error');
268 jqconsole
.Write(exc
+ '\n', 'jqconsole-error');
271 jq_save_history(jqconsole
);
273 jqconsole
.Prompt(true, handler
);
275 jqconsole.Prompt(true, handler, function(command) {
276 // Continue line if can't compile the command.
280 if (/[\[\{\(]$/.test(command)) {
291 // Initiate the first prompt.