-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
61 lines (56 loc) · 1.95 KB
/
test.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
<html>
<head>
<script type="text/javascript" src="src/header.js"></script>
<script type="text/javascript">
//loadZbLisp("src");
function go() {
var d = document;
var src = d.getElementById("src").value;
var results = e(src);
for (var i = 0; i < results.length; i++) {
var out = d.getElementById("out");
out.value =
out.value + results[i].toString() + "\n";
out.scrollTop = out.scrollHeight;
}
}
function zblispdisplay(s) {
out.value = out.value + s;
out.scrollTop = out.scrollHeight;
}
function zblispnewline() {
out.value = out.value + "\n";
out.scrollTop = out.scrollHeight;
}
function test() {
e(Loader.load("test.scm"))
}
function sample() {
var s = "; calculate 20! using applicative order Y combinator\n" +
"(((lambda (r)\n" +
" ((lambda (f) (f f))\n" +
" (lambda (y)\n" +
" (r (lambda (x) ((y y) x))))))\n" +
" (lambda (fact)\n" +
" (lambda (n)\n" +
" (if\n" +
" (= 0 n) 1\n" +
" (* n (fact (- n 1))))))) 20)";
document.getElementById("src").value = s;
go();
}
</script>
</head>
<body>
<textarea id="src" cols="80" rows="8"></textarea>
<br/>
<button onclick="go();">Run</button>
<button onclick="sample();">Run Example Code</button>
<button onclick="test();">Run Tests</button> (not many tests yet)
<br/>
<textarea cols="80" rows="8" id="out"></textarea>
<br/>
Supported: quote, lambda, if, set!, call/cc, =, cons, car, cdr, null?, pair?, +, -, *, /,
define, map, foldl, foldr, list, display, newline, not, let, "named let", let*
</body>
</html>