-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
99 lines (93 loc) · 3.77 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Try Lambda Calculus!</title>
<script type="text/javascript" src="jquery-console/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jquery-console/jquery.console.js"></script>
<script type="text/javascript" src="lc_parser.js"></script>
<script type="text/javascript" src="lc_evaluator.js"></script>
<script type="text/javascript">
function lcEvaluate(line) {
try {
var expr = parser.parse(line);
return evaluator.stringify(evaluator.reduce(expr));
} catch (e) {
return e.message;
}
}
var controller;
function insertCode(code) {
if (controller != undefined) {
controller.typer.consoleInsert(code);
controller.typer.focus();
}
}
$(document).ready(function(){
var lcConsole = $('.lcConsole');
$('body').append(lcConsole);
controller = lcConsole.console({
promptLabel: '> ',
commandValidate: function(line){
if (line == "") return false;
else return true;
},
commandHandle: lcEvaluate,
animateScroll: true,
autofocus: true,
});
});
</script>
<style type="text/css" media="screen">
div.lcConsole { word-wrap: break-word; }
div.lcConsole { font-size: 14px; margin-top:1em }
div.lcConsole div.jquery-console-inner {
width: 40em;
height: 25em;
background:#efefef;
padding:0.5em;
overflow:auto
}
div.lcConsole div.jquery-console-prompt-box {
color:#444; font-family:monospace;
}
div.lcConsole div.jquery-console-focus span.jquery-console-cursor {
background:#333;
color:#eee;
font-weight:bold
}
div.lcConsole div.jquery-console-message-error {
color: #ef0505;
font-family: sans-serif;
font-weight: bold;
padding: 0.1em;
}
div.lcConsole div.jquery-console-message-success {
color:#187718;
font-family:monospace;
padding:0.1em;
}
div.lcConsole span.jquery-console-prompt-label {
color: red;
}
code { background:#efefef; cursor: pointer; }
#by-line {bottom: 1em; position: absolute;}
</style>
</head>
<body>
<h1>Try Lambda Calculus!</h1>
<p>Have two minutes? Give the Lambda Calculus a shot right now!</p>
<p>If you're a beginner you can start with some basics:</p>
<dl>
<dt>Variables!</dt>
<dd><code onclick="insertCode('x')">x</code>, <code onclick="insertCode('y')">y</code>, <code onclick="insertCode('a')">a</code>, and other letters!</dd>
<dt>Functions!</dt>
<dd><code onclick="insertCode('\\x.x')">\x.x</code>, <code onclick="insertCode('\\x.\\y.x')">\x.\y.x</code>, and more!</dd>
<dt>Application!</dt>
<dd><code onclick="insertCode('(\\x.x) \\z.z')">(\x.x) \z.z</code>, <code onclick="insertCode('(\\x.\\y.x) z q')">(\x.\y.x) z q</code>, and even <code onclick="insertCode('(\\x.x x) (\\y.y y)')">(\x.x x) (\y.y y)</code>!</dd>
</dl>
<div class="lcConsole"></div>
<div id="by-line">
<p>Hacked out in a night by <a href="http://mike-burns.com/">Mike Burns</a>. Thanks to <a href="http://tryruby.org/">Try Ruby</a> and <a href="http://tryhaskell.org/">Try Haskell</a>; and to <a href="http://zaach.github.com/jison/">jison</a> and <a href="https://github.com/chrisdone/jquery-console">jquery-console</a>. Learn more about <a href="http://en.wikipedia.org/wiki/Lambda_Calculus">the Lambda Calculus at Wikipedia</a>. Fork <a href="https://github.com/mike-burns/trylambda">the source on Github</a>.</p>
</div>
</body>
</html>