summaryrefslogtreecommitdiff
path: root/tests/general/wordcnt.dat
blob: da17d7a7874d5efe5b690975fd6abd48aac6bc32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#	W O R D   T A B U L A T I O N
#

#  This main procedure processes standard input and writes the results
#  with the words in a column 20 characters wide.

procedure main()
   wordcount(20)
end

procedure wordcount(n)
   local t, line, x, y
   static letters
   initial letters := &lcase ++ &ucase
   t := table(,0)
   every line := !&input do
      scan line using
         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