Skip to content

Comment on Simple Is Not Smallparent

Comments

You can skip `tr` as well - works on BSD awk and GNU awk.

    {
        $0 = tolower($0)
        gsub(/[^[:alpha:]]/, "\n")
        for (i = 1; i <= NF; i++) {
            if (!($i in freq)) order[++n] = $i
            freq[$i]++
        }
    } END {
        for (i = 1; i <= n; i++)
            printf "%d %s\n", freq[order[i]], order[i]
    }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.