home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / awk / awk320.zip / HGRAM.AWK < prev    next >
Text File  |  1990-02-08  |  372b  |  22 lines

  1. # histogram
  2. #   input:  numbers between 0 and 99
  3. #   output: histogram for the deciles
  4.  
  5. # AKW p70
  6.  
  7. {
  8.     x[int($1/10)]++
  9. }
  10.  
  11. END {
  12.     for (i = 0; i < 10; i++)
  13.         printf(" %2d - %2d: %3d %s\n",
  14.             10*i, 10*i+9, x[i], rep(x[i], "*"))
  15. }
  16.  
  17. function rep(n, s,  t) {  # return string of n s's
  18.     while (n-- > 0)
  19.         t = t s
  20.     return t
  21. }
  22.