aboutsummaryrefslogtreecommitdiff
path: root/lib/core/collections.nom
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core/collections.nom')
-rw-r--r--lib/core/collections.nom13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/core/collections.nom b/lib/core/collections.nom
index 60eee3c..02f9302 100644
--- a/lib/core/collections.nom
+++ b/lib/core/collections.nom
@@ -24,7 +24,7 @@ test:
assume (($list, first) == 1)
assume ($list, has 3)
assume (($list, index of 3) == 3)
- assume ((size of $list) == 5)
+ assume ((#$list) == 5)
$list, add 6
assume (($list, last) == 6)
$list, pop
@@ -36,7 +36,7 @@ test:
# Dict functionality
test:
$dict = {.x = 1, .y = 2, .z = 3}
- assume (size of $dict) == 3
+ assume (#$dict) == 3
assume [: for $k = $v in {.x = 1}: add {.key = $k, .value = $v}] ==
[{.key = "x", .value = 1}]
assume ({.x = 1, .y = 1} + {.y = 10, .z = 10}) == {.x = 1, .y = 11, .z = 10}
@@ -44,13 +44,13 @@ test:
assume ({.x = 1, .y = 1} | {.y = 10, .z = 10}) == {.x = 1, .y = 1, .z = 10}
assume ({.x = 1, .y = 1} & {.y = 10, .z = 10}) == {.y = 1}
assume ({.x = 1, .y = 1} ~ {.y = 10, .z = 10}) == {.x = 1, .z = 10}
-
+
# Set compliments:
assume (~{.x}).y
assume ((~{.x}).x == (nil))
$sc = (~{.x, .y})
$sc.y = 99
-
+
# For now, whether $sc.y == 99 or $sc.y == (yes) is unspecified,
(but the actual behavior is (yes))
assume ($sc.y and (not $sc.x))
@@ -180,6 +180,7 @@ test:
for $ in $r:
$visited, add $
assume ($visited == [1, 3, 5, 7, 9])
+
$range_mt = {
.__type = "a Range"
.__index =
@@ -211,8 +212,7 @@ $range_mt = {
($self.last == $other.last) and ($self.step == $other.step)
.backwards = (for $self ($self.last to $self.first by (- $self.step)))
- .__inext = $(inext)
- .__next = $(inext)
+ .__inext = $(inext), .__next = $(inext)
.as_text =
for $self:
if ($self.step == 1):
@@ -220,6 +220,7 @@ $range_mt = {
..else:
return "(\($self.first) to \($self.last) by \($self.step))"
}
+
$range_mt.reversed = $range_mt.backwards
$range_mt.__unm = $range_mt.backwards
$range_mt.__tostring = $range_mt.as_text