Annotation of researchv10dc/vol2/anim/is.awk, revision 1.1

1.1     ! root        1: awk '
        !             2: BEGIN {        n = ARGV[1]     # numer of elements to generate and sort
        !             3:        for (i = 1; i <= n; i++) x[i] = 1 + int(25*rand())
        !             4:        for (i = 2; i <= n; i++) {
        !             5:                for (j = i; j > 1 && x[j] < x[j-1]; j--)
        !             6:                        swap(j-1, j)
        !             7:                show()
        !             8:        }
        !             9: }
        !            10: function swap(i, j,   t) {
        !            11:        t = x[i];  x[i] = x[j];  x[j] = t
        !            12: }
        !            13: function show(  i) {
        !            14:        for (i = 1; i <= n; i++)
        !            15:                printf("%3d", x[i])
        !            16:        printf("\n")
        !            17: }' $*

unix.superglobalmegacorp.com

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