Skip to content

Commit 003b52d

Browse files
committed
Fix sample
1 parent 80bc16a commit 003b52d

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

empty.out

35 Bytes
Binary file not shown.

samples/peano_implicit.vh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import :Prelude
2+
io = import :IO
3+
4+
-- We don't need to define Zero and Succ, they can exist
5+
-- as application of functions, and not mean anything more,
6+
-- they perform no computation like normal functions.
7+
N = [ Zero ] | [ Succ n => n <- N ] where:
8+
Zero : N
9+
Succ : N -> N
10+
11+
(+) : N -> N -> N
12+
n + Zero = n
13+
n + (Succ m) = Succ (n + m)
14+
15+
(*) : N -> N -> N
16+
n * Zero = Zero
17+
n * (Succ m) = n + n * m
18+
19+
one = Succ Zero
20+
two = Succ one
21+
three = two + one
22+
23+
-- Should show: (Succ (Succ (Succ (Succ (Succ Zero)))))
24+
io::puts <| three + two

samples/primes.vh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import :Prelude
2+
io = import :IO
3+
4+
-- Primes is an infinte list.
5+
Primes = [ p : 2... => p mod n /= 0 => n <- 2..p ]
6+
7+
-- The (..) and (...) operators mean:
8+
-- n..m = [ i : Int => i >= n and i < m ]
9+
-- n... = [ i : Int => i >= n ]
10+
-- ...m = [ i : Int => i < m ]
11+
12+
13+
firs_20_primes = take 20 Primes
14+
15+
io::puts first_20_primes

test_source-release.out

90 Bytes
Binary file not shown.

test_source.out

122 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)