From b366bed24bd566396e898bdbbc7721adc25ec369 Mon Sep 17 00:00:00 2001 From: radrow Date: Fri, 25 Jun 2021 11:19:19 +0200 Subject: [PATCH 1/3] Add check in from_to_step --- priv/stdlib/List.aes | 1 + 1 file changed, 1 insertion(+) diff --git a/priv/stdlib/List.aes b/priv/stdlib/List.aes index 9493037..f08e9e4 100644 --- a/priv/stdlib/List.aes +++ b/priv/stdlib/List.aes @@ -80,6 +80,7 @@ namespace List = * `b` only if `(b - a) mod step == 0`. `step` should be bigger than 0. */ function from_to_step(a : int, b : int, s : int) : list(int) = + require(step > 0, "List.from_to_step: non-positive step") from_to_step_(a, b - (b-a) mod s, s, []) private function from_to_step_(a : int, b : int, s : int, acc : list(int)) : list(int) = if(b < a) acc From b22eeffc3db32063ad67ae28ae3bffde8da32be1 Mon Sep 17 00:00:00 2001 From: radrow Date: Sat, 26 Jun 2021 19:10:15 +0200 Subject: [PATCH 2/3] Formatting in stdlib doc --- docs/sophia_stdlib.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/sophia_stdlib.md b/docs/sophia_stdlib.md index 8b7138b..219b27c 100644 --- a/docs/sophia_stdlib.md +++ b/docs/sophia_stdlib.md @@ -1216,7 +1216,7 @@ List.unzip(l : list('a * 'b)) : list('a) * list('b) Opposite to the `zip` operation. Takes a list of pairs and returns pair of lists with respective elements on same indices. -### merge +#### merge ``` List.merge(lesser_cmp : ('a, 'a) => bool, l1 : list('a), l2 : list('a)) : list('a) ``` @@ -1224,7 +1224,7 @@ List.merge(lesser_cmp : ('a, 'a) => bool, l1 : list('a), l2 : list('a)) : list(' Merges two sorted lists into a single sorted list. O(length(l1) + length(l2)) -### sort +#### sort ``` List.sort(lesser_cmp : ('a, 'a) => bool, l : list('a)) : list('a) ``` From 2e6c01cb75ee6032164033b74da0dbe1f93de911 Mon Sep 17 00:00:00 2001 From: radrow Date: Sat, 26 Jun 2021 19:10:49 +0200 Subject: [PATCH 3/3] Fix var --- priv/stdlib/List.aes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/stdlib/List.aes b/priv/stdlib/List.aes index f08e9e4..cf9670e 100644 --- a/priv/stdlib/List.aes +++ b/priv/stdlib/List.aes @@ -80,7 +80,7 @@ namespace List = * `b` only if `(b - a) mod step == 0`. `step` should be bigger than 0. */ function from_to_step(a : int, b : int, s : int) : list(int) = - require(step > 0, "List.from_to_step: non-positive step") + require(s > 0, "List.from_to_step: non-positive step") from_to_step_(a, b - (b-a) mod s, s, []) private function from_to_step_(a : int, b : int, s : int, acc : list(int)) : list(int) = if(b < a) acc