From 61649a5c2e6956485e65349570fdbe0f7ca778fa Mon Sep 17 00:00:00 2001 From: Eloi Torrents Date: Mon, 2 Sep 2024 22:56:38 +0200 Subject: [PATCH 1/3] Fix := syntax in examples --- example/match.bl | 16 ++++++++-------- example/union.bl | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/example/match.bl b/example/match.bl index 7f55837..9eb9cd0 100644 --- a/example/match.bl +++ b/example/match.bl @@ -1,17 +1,17 @@ -def (xs? length) do: +def xs? length = if xs == () then 0 else 1 + (xs tail length) -def (xs? drop n?) do: +def xs? drop n? = match n with: 0 => xs n? => xs tail drop n - 1 -def (xs? take n?) do: +def xs? take n? = match n with: 0 => () n? => xs head :: xs tail take n - 1 -def (merge a? b?) do: +def merge a? b? = match (a, b) with: (a?, ()) => a ((), b?) => b @@ -21,14 +21,14 @@ def (merge a? b?) do: else b head :: (merge a b tail) -def (sort items?) do: +def sort items? = match items with: () => () x? :: () => items xs? => do: - n := xs length - left := xs take n / 2 - right := xs drop n / 2 + def n = xs length + def left = xs take n / 2 + def right = xs drop n / 2 merge (sort left) (sort right) sort (list 4 7 5 2 3 0 1 9 8 6) diff --git a/example/union.bl b/example/union.bl index 97fff33..bb993fa 100644 --- a/example/union.bl +++ b/example/union.bl @@ -1,9 +1,9 @@ -def (unpack x?) do: +def unpack x? = match x with: i? : Int => "int!" s? : String => "string!" -MyType := (Int | String) -x := 1 : MyType +def MyType = (Int | String) +def x = 1 : MyType -unpack x \ No newline at end of file +println unpack x From c8d54c8b95ce5726f36b595064f261ac51ef65c6 Mon Sep 17 00:00:00 2001 From: Eloi Torrents Date: Tue, 3 Sep 2024 09:41:40 +0200 Subject: [PATCH 2/3] Fix def syntax --- example/assoc.bl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/example/assoc.bl b/example/assoc.bl index ddb941a..af414a9 100644 --- a/example/assoc.bl +++ b/example/assoc.bl @@ -1,23 +1,23 @@ -def (K? to V?) : (Type, Type) -> Type do: +def K? to V? : (Type, Type) -> Type = Map of [(K, V)] -def (group pairs?) do: +def group pairs? = match pairs with: () => () x? :: y? :: xs? => (x, y) :: group xs -def (map pairs...?) do: +def map pairs...? = Map of group pairs -def (m? find-key k?) do: +def m? find-key k? = match m with: (k, v?) :: xs? => v e? :: xs? => xs find-key k -def (m? find k?) : (Any to Any, Any) -> Any do: +def m? find k? : (Any to Any, Any) -> Any = match m with: Map of xs? => xs find-key k -def (m? with entry?) : (Any to Any, (Any, Any)) -> Any do: +def m? with entry? : (Any to Any, (Any, Any)) -> Any = match m with: Map of xs? => Map of (entry :: xs) From 18e7c2068afd3ff759e41966450bb414c60aba53 Mon Sep 17 00:00:00 2001 From: Eloi Torrents Date: Wed, 4 Sep 2024 17:45:28 +0200 Subject: [PATCH 3/3] Fix fib example --- example/fib.bl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/fib.bl b/example/fib.bl index 04843c0..8b133af 100644 --- a/example/fib.bl +++ b/example/fib.bl @@ -1,7 +1,9 @@ # Computes fib(10) recursively. -def fib (n? : Int) = +def fib n? : Int = if n < 2 then n else (fib n - 1) + (fib n - 2) + +println fib 10