summaryrefslogtreecommitdiff
path: root/ipl/progs/mapcolrs.icn
blob: 833f77da3c0f76be6c7d5e0bda73d5447832c12a (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
47
48
49
50
51
52
53
54
55
56
57
############################################################################
#
#	File:     mapcolrs.icn
#
#	Subject:  Program to map colors in lists
#
#	Author:   Ralph E. Griswold
#
#	Date:     August 3, 2000
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program maps colors in lists.
#
#  This is a work in progress.
#
############################################################################
#
#  Links:  io, ximage
#
############################################################################

link io 
link ximage

procedure main(args)
   local in_list, to_list, infile, tofile, colors, map, i

   in_list := args[1] | stop("*** no input list specified")
   to_list := args[2] | stop("*** no map list specified")

   infile := dopen(in_list) | stop("*** cannot open ", in_list)
   tofile := dopen(to_list) | stop("*** cannot open ", to_list)

   in_list := []
   write(read(infile))			# header
   while put(in_list, read(infile))
   to_list := []
   while put(to_list, read(tofile))

   colors := table(0)
   every colors[!in_list] +:= 1
   colors := sort(colors, 4)
   map := table()
   every i := 1 to *colors / 2 do {
      pull(colors)
      map[pull(colors)] := i
      }

   xdump(colors)
   xdump(map)

end