1 2 3 4 5 6 7 8
m = map[b = 2, a = 1]
log[keys[m]]
log[values[m]]
log['a' in m]
m2 = set[m, 'c', 3]
log[len[m2]]
log[del[m2, 'b']]
log[m2['c']]expected output — from the book, verified by crow test --book
['a', 'b']
[1, 2]
true
3
[a = 1, c = 3]
3Reference: spec section 8 (Maps) and section 11 (Map Operations).
1 2 3 4
words = ['the', 'cat', 'sat']
at = map[words, range[len[words]]]
log[at['cat']]
log['dog' in at]expected output — from the book, verified by crow test --book
1
false1 2 3 4 5 6 7 8 9 10 11 12 13
scores = map[[7, 3], [0.5, 0.25]]
log[scores[3]]
log[keys[scores]]
log[3 in scores]
by_id = map[1 = 'a', 2 = 'b']
log[by_id[2]]
counts = map[]
for n in [3, 1, 3]
if n in counts
counts = set[counts, n, counts[n] + 1]
else
counts = set[counts, n, 1]
log[counts]expected output — from the book, verified by crow test --book
0.25
[3, 7]
true
b
[1 = 1, 3 = 2]