src/count/count.oxl
const MIN_WORD_LEN: usize = 2
/// Counts the lowercase words longer than `MIN_WORD_LEN` characters.
pub fn countWords(text: str) -> Map<str, u64> pure {
var counts: Map<str, u64> = {:}
for w in text.splitWhitespace() where w.len() > MIN_WORD_LEN {
counts[w.lower()] = (counts.get(w.lower()) ?? 0) + 1
}
counts
}
/// The `n` most frequent words as `word: count` lines, most frequent first (ties by word).
pub fn top(counts: Map<str, u64>, n: i64) -> List<str> pure {
let lines = from (w, c) in counts order by c desc, w take n select "{w}: {c}"
lines.toList()
}Source: examples/wordcount/src/count/count.oxl