aboutsummaryrefslogtreecommitdiff
path: root/test/tables.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-13 13:39:44 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-13 13:39:44 -0400
commit63e6ba596ae8e35727289a69b11d5640bfc5e49e (patch)
tree2a6e3022103f42898da7c02640e2dab817b36b88 /test/tables.tm
parentcc0763713495a2b5b154d318772fc7f745e96635 (diff)
Change table syntax to {key:value} instead of {key=>value}
Diffstat (limited to 'test/tables.tm')
-rw-r--r--test/tables.tm34
1 files changed, 17 insertions, 17 deletions
diff --git a/test/tables.tm b/test/tables.tm
index a55e4238..2ba42714 100644
--- a/test/tables.tm
+++ b/test/tables.tm
@@ -1,6 +1,6 @@
func main()
- >> t := {"one"=>1, "two"=>2; default=999}
- = {"one"=>1, "two"=>2; default=999}
+ >> t := {"one":1, "two":2; default=999}
+ = {"one":1, "two":2; default=999}
>> t["one"]
= 1
@@ -11,24 +11,24 @@ func main()
t_str := ""
for k,v in t
- t_str ++= "({k}=>{v})"
+ t_str ++= "({k}:{v})"
>> t_str
- = "(one=>1)(two=>2)"
+ = "(one:1)(two:2)"
>> #t
= 2
>> t.default
= ?%999
>> t.fallback
- = !{Text=>Int}
+ = !{Text:Int}
>> t.keys
= ["one", "two"]
>> t.values
= [1, 2]
- >> t2 := {"three"=>3; fallback=t}
- = {"three"=>3; fallback={"one"=>1, "two"=>2; default=999}}
+ >> t2 := {"three":3; fallback=t}
+ = {"three":3; fallback={"one":1, "two":2; default=999}}
>> t2["one"]
= 1
@@ -42,17 +42,17 @@ func main()
>> t2.default
= !Int
>> t2.fallback
- = ?%{"one"=>1, "two"=>2; default=999}
+ = ?%{"one":1, "two":2; default=999}
t2_str := ""
for k,v in t2
- t2_str ++= "({k}=>{v})"
+ t2_str ++= "({k}:{v})"
>> t2_str
- = "(three=>3)"
-
- >> {i=>10*i for i in 5}
- = {1=>10, 2=>20, 3=>30, 4=>40, 5=>50}
- >> {i=>10*i for i in 5 if i mod 2 != 0}
- = {1=>10, 3=>30, 5=>50}
- >> {x=>10*x for x in y if x > 1 for y in [3, 4, 5] if y < 5}
- = {2=>20, 3=>30, 4=>40}
+ = "(three:3)"
+
+ >> {i:10*i for i in 5}
+ = {1:10, 2:20, 3:30, 4:40, 5:50}
+ >> {i:10*i for i in 5 if i mod 2 != 0}
+ = {1:10, 3:30, 5:50}
+ >> {x:10*x for x in y if x > 1 for y in [3, 4, 5] if y < 5}
+ = {2:20, 3:30, 4:40}