Baseline: tree as shared
This commit is contained in:
commit
659c03bbf8
1471 files changed
+990535
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# probe: splitting text and counting words in a Dict, in insertion order
|
||||
# status: the expected output is Programming+'s interpreter's prediction; corpus.py verify confirms or refutes it on godbolt
|
||||
# expect-stdout: the 3
|
||||
# expect-stdout: cat 1
|
||||
# expect-stdout: and 2
|
||||
# expect-stdout: hat 1
|
||||
# expect-stdout: bat 1
|
||||
# expect-stdout: distinct: 5
|
||||
def main() raises:
|
||||
var text = String("the cat and the hat and the bat")
|
||||
var counts = Dict[String, Int]()
|
||||
for w in text.split(" "):
|
||||
var word = String(w)
|
||||
if word in counts:
|
||||
counts[word] += 1
|
||||
else:
|
||||
counts[word] = 1
|
||||
for e in counts.items():
|
||||
print(e.key, e.value)
|
||||
print("distinct:", len(counts))
|
||||
Reference in new issue
Block a user