blob: 2d71cadcd695617d2b7fb370e75b397b788faea4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
############################################################################
#
# File: normalize.icn
#
# Subject: Program to normalize numeric channel
#
# Author: Ralph E. Griswold
#
# Date: January 21, 1999
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program reads numbers, one per line, from standard input and
# writes them out normalized so that the largest is 1.0.
#
############################################################################
#
# Links: numbers
#
############################################################################
link numbers
procedure main()
local numbers, colors, line, i, largest
numbers := []
colors := []
while line := read() do {
line ? {
put(numbers, i := tab(upto(' \t') | 0))
put(colors, tab(0))
}
}
largest := real(max ! numbers)
every i := 1 to *numbers do
write(numbers[i] / largest, colors[i])
end
|