2 Copyright (c) 2014 Joel Martin
3 Copyright (c) 2012 Fogus, Jen Myers and Relevance Inc.
4 All rights reserved. The use and distribution terms for this software
5 are covered by the Eclipse Public License 1.0
6 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in
7 the file COPYING the root of this distribution. By using this
8 software in any fashion, you are agreeing to be bound by the terms of
9 this license. You must not remove this notice, or any other, from
15 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/base.css" />
16 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/layout.css" />
17 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/skeleton.css" />
18 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/himera.css" />
19 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/ansi.css" />
20 <link rel=
"stylesheet" type=
"text/css" href=
"js/web/console.css" />
21 <style type=
"text/css" media=
"screen">
23 <title>Mal Web RELP
</title>
26 <div class=
"container">
27 <h1 id=
"title"><a href=
"https://github.com/kanaka/mal"/>Mal
</a></h1>
32 <div id="editor-container" class="sixteen columns">
33 <div id="tiny-note" class="tiny-note"></div>
34 <textarea class="editor" id="editor">;; Develop your Mal program here.
35 ;; Ctrl+E/Cmd+E evaluates file in the REPL.</textarea>
39 <div id=
"console-container" class=
"sixteen columns">
40 <div class=
"console" id=
"console"></div>
42 <div class=
"eight columns">
44 <h3><span style="cursor: pointer" class="doc-link" id="toggle-editor">Show file editor</span></h3>
46 <h3><span style=
"cursor: pointer" class=
"doc-link"> </span></h3>
48 <div class=
"eight columns">
50 <a href=
"http://github.com/kanaka/mal">View source on Github
<img src=
"js/web/github-icon.png" /></a></p>
51 </div><!-- /source -->
54 <div class=
"rule sixteen columns"></div>
56 <div class=
"sixteen columns">
57 <h3>Mal at a glance
</h3>
60 <div class=
"cheat-box-container eight columns">
61 <div class=
"cheat-box">
65 <td class=
"row-label">Maps
</td>
66 <td>{
"key1" "val1",
"key2" 123}
</td>
69 <td class=
"row-label">Lists
</td>
70 <td>(
1 2 3 "four")
</td>
73 <td class=
"row-label">Vectors
</td>
74 <td>[
1 2 3 4 "a" "b" "c" 1 2]
</td>
77 <td class=
"row-label">Scalars
</td>
78 <td>a-symbol,
"a string",
123, nil, true, false
</td>
81 </div><!-- /cheat-box -->
82 <div class=
"cheat-box">
86 <td class=
"row-label">Calling
</td>
87 <td>(
<span class=
"ebnf"><function
></span>
88 <span class=
"ebnf"><args*
></span>)
</td>
91 <td class=
"row-label">Defining named functions
</td>
92 <td>(def!
<span class=
"ebnf"><name
></span>
94 [
<span class=
"ebnf"><args*
></span>]
95 <span class=
"ebnf"><action*
></span>))
</td>
98 <td class=
"row-label">Anonymous function
</td>
99 <td>(fn*
<span class=
"ebnf">|name|
</span>
100 [
<span class=
"ebnf"><args*
></span>]
101 <span class=
"ebnf"><action*
></span>)
</td>
104 </div><!-- /cheat-box -->
105 <div class=
"cheat-box">
106 <h4>Useful Macros and Special Forms
</h4>
109 <td class=
"row-label">Conditionals
</td>
114 <td class="row-label">Nesting, chaining, and Interop</td>
115 <td>-> ->> doto .. .</td>
119 <td class=
"row-label">Multiple Actions (side-effects)
</td>
121 <span class=
"ebnf"><action*
></span>...)
</td>
124 <td class=
"row-label">Defining things
</td>
125 <td>def! defmacro! let*
</td>
129 </div><!-- /cheat-box-container -->
131 <div class=
"cheat-box-container eight columns">
132 <div class=
"cheat-box">
133 <h4>Useful Functions
</h4>
136 <td class=
"row-label">Math
</td>
140 <td class=
"row-label">Comparison/Boolean
</td>
141 <td>= <
> <=
>= not
</td>
144 <td class=
"row-label">Predicates
</td>
145 <td>nil? true? false? symbol? list? vector? map? sequential?
</td>
148 <td class=
"row-label">Data processing
</td>
152 <td class=
"row-label">Data create
</td>
153 <td>list vector hash-map
</td>
156 <td class=
"row-label">Data inspection
</td>
157 <td>first rest get keys vals count get nth contains? empty?
</td>
160 <td class=
"row-label">Data manipulation
</td>
161 <td>conj cons concat assoc dissoc
</td>
164 <td class=
"row-label">Lists and Vectors
</td>
165 <td>first rest nth
</td></td>
168 <td class=
"row-label">Hash Maps
</td>
169 <td>get keys vals contains?
</td></td>
172 </div><!-- /cheat-box -->
173 <div class=
"cheat-box">
174 <h4>JavaScript Interop
</h4>
177 <td class=
"row-label">Evaluate JavaScript
</td>
178 <td>(js*
"JS string to eval")
</td>
181 <td class=
"row-label">Method call/access
</td>
182 <td>(. js-fn arg...)
</td>
186 </div><!-- /cheat-box-container -->
188 <div class=
"rule sixteen columns"></div>
190 <div class=
"column footer-logo">
191 <div>Mal
© 2013 Joel Martin
</div>
192 <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>
195 </div><!-- / container -->
196 <script type=
"text/javascript" src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
197 <script type=
"text/javascript" src=
"js/web/jqconsole.min.js"></script>
198 <script type=
"text/javascript" src=
"js/web/mal.js"></script>
201 // Creating the console.
202 window
.jqconsole
= $('#console').jqconsole(null, 'user> ');
204 printer
.println = function () {
205 var str
= Array
.prototype.join
.call(arguments
, " ")
206 jqconsole
.Write(str
+ "\n", 'jqconsole-output');
209 rep("(println (str \"Mal [\" *host-language* \"]\"))");
211 jq_load_history(jqconsole
);
213 // Abort prompt on Ctrl+C.
214 jqconsole
.RegisterShortcut('C', function() {
215 jqconsole
.AbortPrompt();
218 // Move to line start Ctrl+A.
219 jqconsole
.RegisterShortcut('A', function() {
220 jqconsole
.MoveToStart();
223 // Move to line end Ctrl+E.
224 jqconsole
.RegisterShortcut('E', function() {
225 jqconsole
.MoveToEnd();
228 jqconsole
.RegisterMatching('{', '}', 'brace');
229 jqconsole
.RegisterMatching('(', ')', 'paren');
230 jqconsole
.RegisterMatching('[', ']', 'bracket');
231 jqconsole
.RegisterMatching('"', '"', 'dquote');
233 var handler = function(line
) {
236 jqconsole
.Write(rep(line
) + '\n', 'jqconsole-return');
238 if (exc
instanceof reader
.BlankException
) { return; }
240 jqconsole
.Write(exc
.stack
+ '\n', 'jqconsole-error');
242 jqconsole
.Write(exc
+ '\n', 'jqconsole-error');
245 jq_save_history(jqconsole
);
247 jqconsole
.Prompt(true, handler
);
249 jqconsole.Prompt(true, handler, function(command) {
250 // Continue line if can't compile the command.
254 if (/[\[\{\(]$/.test(command)) {
265 // Initiate the first prompt.