diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-08-29 15:59:30 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-08-29 16:00:04 -0700 |
| commit | 811fdd685670d2eb8c6bcb9e6e103e57bf402ca8 (patch) | |
| tree | c599fd7a609159c2ec50a30f1131000070e8eb03 /core | |
| parent | 22495c7d708b4950b83c5bc9b97806e19cd1fcfa (diff) | |
Tweaked version 3.6 to include deprecating list append/removal functions
in favor of using a method call style.
Diffstat (limited to 'core')
| -rw-r--r-- | core/collections.nom | 14 | ||||
| -rw-r--r-- | core/control_flow.nom | 16 | ||||
| -rw-r--r-- | core/coroutines.nom | 2 |
3 files changed, 16 insertions, 16 deletions
diff --git a/core/collections.nom b/core/collections.nom index cba20f9..aade458 100644 --- a/core/collections.nom +++ b/core/collections.nom @@ -58,9 +58,9 @@ test: %list = [1, 2, 3, 4, 5] append 6 to %list assume ((last in %list) is 6) - pop from %list + %list::pop assume ((last in %list) is 5) - remove index 1 from %list + %list::remove index 1 assume ((first in %list) is 2) compile [..] append %item to %list, add %item to %list, to %list add %item, to %list append %item @@ -85,7 +85,7 @@ parse [%expression for %item in %iterable] as (..) result of: %comprehension = [] for %item in %iterable: - add %expression to %comprehension + %comprehension::add %expression return %comprehension parse [..] @@ -95,7 +95,7 @@ parse [..] result of: %comprehension = [] for %index in %start to %stop via %step: - add %expression to %comprehension + %comprehension::add %expression return %comprehension ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -114,7 +114,7 @@ parse [..] result of: %comprehension = [] for %key = %value in %iterable: - add %expression to %comprehension + %comprehension::add %expression return %comprehension # Dict comprehensions @@ -164,7 +164,7 @@ test: action [%lists flattened]: %flat = [] for %list in %lists: - for %item in %list: add %item to %flat + for %item in %list: %flat::add %item return %flat test: @@ -240,7 +240,7 @@ action [unique %items]: %seen = {} for % in %items: unless %seen.%: - add % to %unique + %unique::add % %seen.% = (yes) return %unique diff --git a/core/control_flow.nom b/core/control_flow.nom index 95b9bcb..63601f7 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -172,19 +172,19 @@ compile [===next %var ===, ---next %var ---, ***next %var ***] to (..) test: %nums = [] - for %x in 1 to 5: add %x to %nums + for %x in 1 to 5: %nums::add %x assume (%nums == [1, 2, 3, 4, 5]) %nums = [] - for %x in 1 to 5 via 2: add %x to %nums + for %x in 1 to 5 via 2: %nums::add %x assume (%nums == [1, 3, 5]) %nums = [] for %outer in 1 to 100: for %inner in %outer to (%outer + 2): if (%inner == 2): - add -2 to %nums + %nums::add -2 do next %inner - add %inner to %nums + %nums::add %inner if (%inner == 5): stop %outer assume (%nums == [1, -2, 3, -2, 3, 4, 3, 4, 5]) @@ -227,13 +227,13 @@ parse [for %var in %start to %stop %body] as (..) test: %a = [10, 20, 30, 40, 50] %b = [] - for %x in %a: add %x to %b + for %x in %a: %b::add %x assume (%a == %b) %b = [] for %x in %a: if (%x == 10): do next %x if (%x == 50): stop %x - add %x to %b + %b::add %x assume (%b == [20, 30, 40]) @@ -268,7 +268,7 @@ test: for %k = %v in %d: if (%k == "a"): do next %k if (%v == 20): do next %v - add "\%k = \%v" to %result + %result::add "\%k = \%v" assume ((%result sorted) == ["c = 30", "d = 40", "e = 50"]) @@ -486,7 +486,7 @@ test: for % in recursive %t: if ((type of %) is "table"): for %2 in %: recurse % on %2 - ..else: add % to %flat + ..else: %flat::add % assume ((sorted %flat) == [1, 2, 3, 4, 5, 6]) diff --git a/core/coroutines.nom b/core/coroutines.nom index 1570ed7..80f3b60 100644 --- a/core/coroutines.nom +++ b/core/coroutines.nom @@ -12,7 +12,7 @@ test: -> 5 repeat 3 times: -> 6 - for % in coroutine %co: add % to %nums + for % in coroutine %co: %nums::add % assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed" compile [coroutine %body, generator %body] to (..) Lua value ".." |
