Files
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

21 lines
709 B
Mojo

# 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))