File:  [CSRG BSD Unix] / 43BSD / contrib / icon / samples / wordcount.icn
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#
#          W O R D   C O U N T I N G
#

#  This program tabulates the words in standard input and writes the
#  results with the words in a column 20 characters wide.  The definition
#  of a "word" is naive.

procedure main()
   wordcount(20)
end

procedure wordcount(n)
   local t, line, x, y
   static letters
   initial letters := &lcase ++ &ucase
   t := table(0)
   while line := read() do
      line ? while tab(upto(letters)) do
         t[tab(many(letters))] +:= 1
   x := sort(t)
   every y := !x do write(left(y[1],n),y[2])
end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.