aboutsummaryrefslogtreecommitdiff
path: root/mal.html
diff options
context:
space:
mode:
Diffstat (limited to 'mal.html')
-rw-r--r--mal.html331
1 files changed, 259 insertions, 72 deletions
diff --git a/mal.html b/mal.html
index 45e6dc3..3bc5b21 100644
--- a/mal.html
+++ b/mal.html
@@ -1,81 +1,268 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!--
+Copyright (c) 2014 Joel Martin
+Copyright (c) 2012 Fogus, Jen Myers and Relevance Inc.
+All rights reserved. The use and distribution terms for this software
+are covered by the Eclipse Public License 1.0
+(http://opensource.org/licenses/eclipse-1.0.php) which can be found in
+the file COPYING the root of this distribution. By using this
+software in any fashion, you are agreeing to be bound by the terms of
+this license. You must not remove this notice, or any other, from
+this software.
+-->
+
<html>
- <head>
- <link rel="stylesheet" href="js/web/ansi.css" type="text/css" media="all" />
- <link rel="stylesheet" href="js/web/console.css" type="text/css" media="all" />
- </head>
- <body>
- <div id="console"></div>
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="js/web/jqconsole.min.js"></script>
- <script src="js/web/mal.js"></script>
- <script>
- $(function() {
- // Creating the console.
- window.jqconsole = $('#console').jqconsole(null, 'user> ');
+<head>
+ <link rel="stylesheet" type="text/css" href="js/web/base.css" />
+ <link rel="stylesheet" type="text/css" href="js/web/layout.css" />
+ <link rel="stylesheet" type="text/css" href="js/web/skeleton.css" />
+ <link rel="stylesheet" type="text/css" href="js/web/himera.css" />
+ <link rel="stylesheet" type="text/css" href="js/web/ansi.css" />
+ <link rel="stylesheet" type="text/css" href="js/web/console.css" />
+ <style type="text/css" media="screen">
+ </style>
+ <title>Mal Web RELP</title>
+</head>
+<body>
+ <div class="container">
+ <h1 id="title"><a href="https://github.com/kanaka/mal"/>Mal</a></h1>
+
+ <h2>Mal Web REPL</h2>
- printer.println = function () {
- var str = Array.prototype.join.call(arguments, " ")
- jqconsole.Write(str + "\n");
- }
+ <!--
+ <div id="editor-container" class="sixteen columns">
+ <div id="tiny-note" class="tiny-note"></div>
+ <textarea class="editor" id="editor">;; Develop your Mal program here.
+;; Ctrl+E/Cmd+E evaluates file in the REPL.</textarea>
+ </div>
+ -->
+
+ <div id="console-container" class="sixteen columns">
+ <div class="console" id="console"></div>
+ </div>
+ <div class="eight columns">
+ <!--
+ <h3><span style="cursor: pointer" class="doc-link" id="toggle-editor">Show file editor</span></h3>
+ -->
+ <h3><span style="cursor: pointer" class="doc-link">&nbsp;</span></h3>
+ </div>
+ <div class="eight columns">
+ <div class="source">
+ <a href="http://github.com/kanaka/mal">View source on Github <img src="js/web/github-icon.png" /></a></p>
+ </div><!-- /source -->
+ </div>
+
+ <div class="rule sixteen columns"></div>
- rep("(println (str \"Mal [\" *host-language* \"]\"))");
+ <div class="sixteen columns">
+ <h3>Mal at a glance</h3>
+ </div>
+
+ <div class="cheat-box-container eight columns">
+ <div class="cheat-box">
+ <h4>Datatypes</h4>
+ <table>
+ <tr class="row-one">
+ <td class="row-label">Maps</td>
+ <td>{"key1" "val1", "key2" 123}</td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Lists</td>
+ <td>(1 2 3 "four")</td>
+ </tr>
+ <tr>
+ <td class="row-label">Vectors</td>
+ <td>[1 2 3 4 "a" "b" "c" 1 2]</td>
+ </tr>
+ <tr>
+ <td class="row-label">Scalars</td>
+ <td>a-symbol, "a string", 123, nil, true, false</td>
+ </tr>
+ </table>
+ </div><!-- /cheat-box -->
+ <div class="cheat-box">
+ <h4>Functions</h4>
+ <table>
+ <tr class="row-one">
+ <td class="row-label">Calling</td>
+ <td>(<span class="ebnf">&lt;function&gt;</span>
+ <span class="ebnf">&lt;args*&gt;</span>)</td>
+ </tr>
+ <tr>
+ <td class="row-label">Defining named functions</td>
+ <td>(def! <span class="ebnf">&lt;name&gt;</span>
+ (fn*
+ [<span class="ebnf">&lt;args*&gt;</span>]
+ <span class="ebnf">&lt;action*&gt;</span>))</td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Anonymous function</td>
+ <td>(fn* <span class="ebnf">|name|</span>
+ [<span class="ebnf">&lt;args*&gt;</span>]
+ <span class="ebnf">&lt;action*&gt;</span>)</td>
+ </tr>
+ </table>
+ </div><!-- /cheat-box -->
+ <div class="cheat-box">
+ <h4>Useful Macros and Special Forms</h4>
+ <table>
+ <tr class="row-one">
+ <td class="row-label">Conditionals</td>
+ <td>if cond or</td>
+ </tr>
+ <!--
+ <tr>
+ <td class="row-label">Nesting, chaining, and Interop</td>
+ <td>-> ->> doto .. .</td>
+ </tr>
+ -->
+ <tr>
+ <td class="row-label">Multiple Actions (side-effects)</td>
+ <td>(do
+ <span class="ebnf">&lt;action*&gt;</span>...)</td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Defining things</td>
+ <td>def! defmacro! let*</td>
+ </tr>
+ </table>
+ </div>
+ </div><!-- /cheat-box-container -->
- // Abort prompt on Ctrl+C.
- jqconsole.RegisterShortcut('C', function() {
- jqconsole.AbortPrompt();
- handler();
- });
- // Move to line start Ctrl+A.
- jqconsole.RegisterShortcut('A', function() {
- jqconsole.MoveToStart();
- handler();
- });
- // Move to line end Ctrl+E.
- jqconsole.RegisterShortcut('E', function() {
- jqconsole.MoveToEnd();
- handler();
- });
- jqconsole.RegisterMatching('{', '}', 'brace');
- jqconsole.RegisterMatching('(', ')', 'paren');
- jqconsole.RegisterMatching('[', ']', 'bracket');
- jqconsole.RegisterMatching('"', '"', 'dquote');
- // Handle a command.
- var handler = function(line) {
- if (line) {
- try {
- jqconsole.Write(rep(line) + '\n');
- } catch (exc) {
- if (exc instanceof reader.BlankException) { return; }
- if (exc.stack) {
- jqconsole.Write(exc.stack + '\n');
- } else {
- jqconsole.Write(exc + '\n');
- }
+ <div class="cheat-box-container eight columns">
+ <div class="cheat-box">
+ <h4>Useful Functions</h4>
+ <table>
+ <tr class="row-one">
+ <td class="row-label">Math</td>
+ <td>+ - * /</td>
+ </tr>
+ <tr>
+ <td class="row-label">Comparison/Boolean</td>
+ <td>= < > <= >= not</td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Predicates</td>
+ <td>nil? true? false? symbol? list? vector? map? sequential?</td>
+ </tr>
+ <tr>
+ <td class="row-label">Data processing</td>
+ <td>map apply</td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Data create</td>
+ <td>list vector hash-map</td>
+ </tr>
+ <tr>
+ <td class="row-label">Data inspection</td>
+ <td>first rest get keys vals count get nth contains? empty?</td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Data manipulation</td>
+ <td>conj cons concat assoc dissoc</td>
+ </tr>
+ <tr>
+ <td class="row-label">Lists and Vectors</td>
+ <td>first rest nth</td></td>
+ </tr>
+ <tr class="row-one">
+ <td class="row-label">Hash Maps</td>
+ <td>get keys vals contains?</td></td>
+ </tr>
+ </table>
+ </div><!-- /cheat-box -->
+ <div class="cheat-box">
+ <h4>JavaScript Interop</h4>
+ <table>
+ <tr class="row-one">
+ <td class="row-label">Evaluate JavaScript</td>
+ <td>(js* "JS string to eval")</td>
+ </tr>
+ <tr>
+ <td class="row-label">Method call/access</td>
+ <td>(. js-fn arg...)</td>
+ </tr>
+ </table>
+ </div>
+ </div><!-- /cheat-box-container -->
+
+ <div class="rule sixteen columns"></div>
+
+ <div class="column footer-logo">
+ <div>Mal &copy; 2013 Joel Martin</div>
+ <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>
+ </div>
+
+ </div><!-- / container -->
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
+ <script type="text/javascript" src="js/web/jqconsole.min.js"></script>
+ <script type="text/javascript" src="js/web/mal.js"></script>
+ <script>
+ $(function() {
+ // Creating the console.
+ window.jqconsole = $('#console').jqconsole(null, 'user> ');
+
+ printer.println = function () {
+ var str = Array.prototype.join.call(arguments, " ")
+ jqconsole.Write(str + "\n", 'jqconsole-output');
+ }
+
+ rep("(println (str \"Mal [\" *host-language* \"]\"))");
+
+ // Abort prompt on Ctrl+C.
+ jqconsole.RegisterShortcut('C', function() {
+ jqconsole.AbortPrompt();
+ handler();
+ });
+ // Move to line start Ctrl+A.
+ jqconsole.RegisterShortcut('A', function() {
+ jqconsole.MoveToStart();
+ handler();
+ });
+ // Move to line end Ctrl+E.
+ jqconsole.RegisterShortcut('E', function() {
+ jqconsole.MoveToEnd();
+ handler();
+ });
+ jqconsole.RegisterMatching('{', '}', 'brace');
+ jqconsole.RegisterMatching('(', ')', 'paren');
+ jqconsole.RegisterMatching('[', ']', 'bracket');
+ jqconsole.RegisterMatching('"', '"', 'dquote');
+ // Handle a command.
+ var handler = function(line) {
+ if (line) {
+ try {
+ jqconsole.Write(rep(line) + '\n', 'jqconsole-return');
+ } catch (exc) {
+ if (exc instanceof reader.BlankException) { return; }
+ if (exc.stack) {
+ jqconsole.Write(exc.stack + '\n', 'jqconsole-error');
+ } else {
+ jqconsole.Write(exc + '\n', 'jqconsole-error');
}
}
- jqconsole.Prompt(true, handler);
- /*
- jqconsole.Prompt(true, handler, function(command) {
- // Continue line if can't compile the command.
- try {
- Function(command);
- } catch (e) {
- if (/[\[\{\(]$/.test(command)) {
- return 1;
- } else {
- return 0;
- }
+ }
+ jqconsole.Prompt(true, handler);
+ /*
+ jqconsole.Prompt(true, handler, function(command) {
+ // Continue line if can't compile the command.
+ try {
+ Function(command);
+ } catch (e) {
+ if (/[\[\{\(]$/.test(command)) {
+ return 1;
+ } else {
+ return 0;
}
- return false;
- });
- */
- };
+ }
+ return false;
+ });
+ */
+ };
- // Initiate the first prompt.
- handler();
- });
- </script>
- </body>
+ // Initiate the first prompt.
+ handler();
+ });
+ </script>
+
+</body>
</html>