1
# indirectcall.awk --- Demonstrate indirect function calls
3
# Arnold Robbins, arnold@skeeve.com, Public Domain
5
# average --- return the average of the values in fields $first - $last
7
function average(first, last, sum, i)
10
for (i = first; i <= last; i++)
13
return sum / (last - first + 1)
16
# sum --- return the sum of the values in fields $first - $last
18
function sum(first, last, ret, i)
21
for (i = first; i <= last; i++)
26
# For each record, print the class name and the requested statistics
29
gsub(/_/, " ", class_name) # Replace _ with spaces
32
for (i = 1; i <= NF; i++) {
39
printf("%s:\n", class_name)
40
for (i = 2; $i != "data:"; i++) {
42
printf("\t%s: <%s>\n", $i, @the_function(start, NF) "")
46
1
# num_lt --- do a numeric less than comparison
48
3
function num_lt(left, right)