#!/bin/csh -f

# Produces histogram of initial field of lines from standard input
# Represents each score with the symbol in the second field of the
# line (default "*").  Lines with initial fields that are not numeric
# or within the range -infty to infty with infty=1000000 are ignored.

cat $* | \
awk 'BEGIN {infty=1000000; bottomval=infty; topval=-infty}\
     {bar[$1]=bar[$1]$2;\
      if (NF == 1) bar[$1]=bar[$1]"*";\
      if (-infty < $1 && $1 < bottomval) bottomval=$1;\
      if (infty > $1 && $1 > topval) topval=$1;}\
     END {for (i=topval; i>=bottomval; i--) printf "%3d %s\n", i, bar[i];}'
