commit 003b52dfd433c0d036ee435213c608f82f974320
parent 80bc16ae93b4dcc0a1d25c8918adfd98091770b6
Author: Demonstrandum <moi@knutsen.co>
Date: Thu, 11 Jun 2020 19:13:04 +0100
Fix sample
Diffstat:
5 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/empty.out b/empty.out
Binary files differ.
diff --git a/samples/peano_implicit.vh b/samples/peano_implicit.vh
@@ -0,0 +1,24 @@
+import :Prelude
+io = import :IO
+
+-- We don't need to define Zero and Succ, they can exist
+-- as application of functions, and not mean anything more,
+-- they perform no computation like normal functions.
+N = [ Zero ] | [ Succ n => n <- N ] where:
+ Zero : N
+ Succ : N -> N
+
+(+) : N -> N -> N
+n + Zero = n
+n + (Succ m) = Succ (n + m)
+
+(*) : N -> N -> N
+n * Zero = Zero
+n * (Succ m) = n + n * m
+
+one = Succ Zero
+two = Succ one
+three = two + one
+
+-- Should show: (Succ (Succ (Succ (Succ (Succ Zero)))))
+io::puts <| three + two
diff --git a/samples/primes.vh b/samples/primes.vh
@@ -0,0 +1,15 @@
+import :Prelude
+io = import :IO
+
+-- Primes is an infinte list.
+Primes = [ p : 2... => p mod n /= 0 => n <- 2..p ]
+
+-- The (..) and (...) operators mean:
+-- n..m = [ i : Int => i >= n and i < m ]
+-- n... = [ i : Int => i >= n ]
+-- ...m = [ i : Int => i < m ]
+
+
+firs_20_primes = take 20 Primes
+
+io::puts first_20_primes
diff --git a/test_source-release.out b/test_source-release.out
Binary files differ.
diff --git a/test_source.out b/test_source.out
Binary files differ.