forked from hkust-taco/mlscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocal_testing.html
More file actions
44 lines (37 loc) · 1007 Bytes
/
local_testing.html
File metadata and controls
44 lines (37 loc) · 1007 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="index.css">
<title>MLscript demonstration</title>
</head>
<body>
<h1>MLscript demonstration</h1>
<div id="content">
<textarea id="mlscript-input" class="panel" spellcheck="false">
type List[A] = Cons[A] | Nil
class Cons[out A](head: A, tail: List[A]) {
fun map: (A -> 'B) -> List['B]
map(f) = Cons of f(head), tail.map(f)
}
module Nil {
fun map(f) = Nil
}
fun (::) cons(x, xs) = Cons(x, xs)
fun show(xs) =
let rec go(xs) = if xs is
Cons(h, Nil) then String(h)
Cons(h, t) then join(String(h), ", ", go(t))
Nil then ""
join("[", go(xs), "]")
let xs = 1 :: 2 :: 3 :: Nil
show(xs)
show(xs.map of x => succ(x))
</textarea>
<div id="mlscript-output" class="panel"></div>
</div>
<script type="text/javascript" src="js/target/scala-2.13/mlscript-fastopt/main.js"></script>
<br/>
<!-- <p>The code is available TODO.</p> -->
<br/>
</html>