Given a phrase, count the occurrences of each word in that phrase.
For the purposes of this exercise you can expect that a word will always be one of:
When counting words you can assume the following rules:
For example, for the phrase
"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled. the count would be:
that's: 1 the: 2 password: 2 123: 1 cried: 1 special: 1 agent: 1 so: 1 i: 1 fled: 1
make chez if you're using ChezScheme or
make guile if you're using GNU Guile.
Sometimes the name for the scheme binary on your system will differ from the defaults.
When this is the case, you'll need to tell make by running
make chez chez=your-chez-binary or
make guile guile=your-guile-binary.
(load "test.scm")at the repl prompt.
word-count.scmreloading as you go.
(test)to check your solution.
If some of the test cases fail, you should see the failing input and the expected output.
The failing input is presented as a list because the tests call your solution by
(apply word-count input-list).
To learn more about
apply see The Scheme Programming Language -- Chapter 5