Tin

Examples · learn/08-collections · 145 of 339

task-2.solution

examples/learn/08-collections/task-2.solution.tintin run examples/learn/08-collections/task-2.solution.tin
fn main() {
  let text = "the cat saw the dog and the cat ran"
  var counts: Map<string, int> = newMap()
  for word in text.split(" ") {
    counts.set(word, counts.get(word).or(0) + 1)
  }
  for word, n in counts {
    print("{word}: {n}")
  }
}