OxL Reference

wordcount

The utility of Standard V.2: it reads a file, counts the words longer than two characters and prints the ten most frequent.

sh
oxl run examples/wordcount -- docs/site/README.md

What to look at:

  • @error data Usage and the result () | Usage | IoError of main: no argument is fail Usage{…}, a read error is passed on with ? (§6.5); an unhandled error ends the process with a non-zero exit code.
  • Map<str, u64> and counts[w.lower()] = … + 1 (§3.3).
  • The query from (w, c) in counts order by c desc, w take n select "{w}: {c}" (§5.9), a lazy iterator.
  • where in the header of a for loop: a filter without a nested if.

Project files · Download (zip)