diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-11 13:50:01 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-11 13:52:46 -0500 |
| commit | 7f8f2117799cdfa6b62909a9182b5adade1d0bd2 (patch) | |
| tree | 1db466db870768e952f50572453660e090e434e0 /examples | |
| parent | 630f910563b6f27dd34a4a0496a43d32539eadcb (diff) | |
| parent | 02886fab651d3f64d2c8ded5597e6c075dc69b5f (diff) | |
Merge branch 'dev' into constructive-reals
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/learnxiny.tm | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm index 746e11a1..7af75880 100644 --- a/examples/learnxiny.tm +++ b/examples/learnxiny.tm @@ -99,7 +99,7 @@ func main() break x # This is the same as `stop x` # Tables are efficient hash maps - table := {"one"=1, "two"=2} + table := {"one": 1, "two": 2} assert table["two"] == 2 # The value returned is optional because none will be returned if the key @@ -130,19 +130,19 @@ func main() # Tables can have a fallback table that's used as a fallback when the key # isn't found in the table itself: - table2 := {"three"=3; fallback=table} + table2 := {"three": 3; fallback=table} assert table2["two"]! == 2 assert table2["three"]! == 3 # Tables can also be created with comprehension loops: - assert {x=10*x for x in 5} == {1=10, 2=20, 3=30, 4=40, 5=50} + assert {x: 10*x for x in 5} == {1: 10, 2: 20, 3: 30, 4: 40, 5: 50} # If no default is provided and a missing key is looked up, the program # will print an error message and halt. # Any types can be used in tables, for example, a table mapping lists to # strings: - table3 := {[10, 20]="one", [30, 40, 50]="two"} + table3 := {[10, 20]: "one", [30, 40, 50]: "two"} assert table3[[10, 20]]! == "one" # So far, the datastructures that have been discussed are all *immutable*, @@ -248,7 +248,7 @@ func demo_structs() assert "$alice" == 'Person(name="Alice", age=30)' == yes - table := {alice="first", bob="second"} + table := {alice: "first", bob: "second"} assert table[alice]! == "first" |
