forked from IoLanguage/iolanguage.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
46 lines (44 loc) · 3.56 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>Core Programming Language</title>
<link rel="stylesheet" href="css/base.css">
</head>
<body>
<div class="container leftSpace">
<header>
<div class="pageHeader">
<div class="topSpace"></div>
<div class="pageTitle">Core</div>
<div class="pageSubtitle">a modern, minimal programming language</div>
</div>
</header>
<main class="example">
<pre>
<span class="core-keyword">class</span> <span class="core-type">Cat</span>(<span class="core-keyword">let</span> <span class="core-member">name</span>: <span class="core-type">String</span>, <span class="core-keyword">let</span> <span class="core-member">lives</span>: <span class="core-type">Int64</span>)
<span class="core-keyword">class</span> <span class="core-type">Dog</span>(<span class="core-keyword">let</span> <span class="core-member">name</span>: <span class="core-type">String</span>, <span class="core-keyword">let</span> <span class="core-member">years</span>: <span class="core-type">Int64</span>)
<span class="core-keyword">union</span> <span class="core-type">Pet</span> <span class="core-keyword">of</span> <span class="core-type">Cat</span>, <span class="core-type">Dog</span>
<span class="core-keyword">fun</span> describe(<span class="core-member">pet</span>: <span class="core-type">Pet</span>): <span class="core-type">String</span> = <span class="core-keyword">if</span> <span class="core-member">pet</span>
... <span class="core-keyword">is</span> <span class="core-type">Cat</span>(<span class="core-keyword">let</span> <span class="core-member">name</span>, <span class="core-keyword">let</span> <span class="core-member">lives</span>) { <span class="core-literal">"cat <span class="core-interp">$name</span> has <span class="core-interp">$lives</span> lives"</span> }
... <span class="core-keyword">is</span> <span class="core-type">Dog</span>(<span class="core-keyword">let</span> <span class="core-member">name</span>, <span class="core-keyword">let</span> <span class="core-member">years</span>) { <span class="core-literal">"dog <span class="core-interp">$name</span> is <span class="core-interp">$years</span> of age"</span> }
<span class="core-type">List</span>(<span class="core-type">Cat</span>(<span class="core-literal">"Lila"</span>, <span class="core-literal">7</span>), <span class="core-type">Dog</span>(<span class="core-literal">"Fenton"</span>, <span class="core-literal">6</span>), <span class="core-type">Cat</span>(<span class="core-literal">"Molly"</span>, <span class="core-literal">9</span>))
.retain(|<span class="core-member">p</span>| <span class="core-member">p</span>.name.size > <span class="core-literal">5</span>)
.map (|<span class="core-member">p</span>| describe(<span class="core-member">p</span>))
.each (|<span class="core-member">d</span>| println(<span class="core-member">d</span>))
<span class="core-comment">// → cat Molly has 9 lives</span>
<span class="core-comment">// → dog Fenton is 6 years of age</span></pre>
</main>
<nav>
<ul>
<div class="link"><a href="about">about</a></div>
<div class="link"><a href="design">design</a></div>
<div class="link"><a href="status">status</a></div>
<div class="link"><a href="tutorial">tutorial</a></div>
<div class="link"><a href="changes">changes</a></div>
<div class="linkFar"><a href="https://github.com/core-lang/core" target="_blank">source</a></div>
</ul>
</nav>
</div>
</body>
</html>