home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / mapcolrs.icn < prev    next >
Text File  |  2000-08-03  |  1KB  |  58 lines

  1. ############################################################################
  2. #
  3. #    File:     mapcolrs.icn
  4. #
  5. #    Subject:  Program to map colors in lists
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     August 3, 2000
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program maps colors in lists.
  18. #
  19. #  This is a work in progress.
  20. #
  21. ############################################################################
  22. #
  23. #  Links:  io, ximage
  24. #
  25. ############################################################################
  26.  
  27. link io 
  28. link ximage
  29.  
  30. procedure main(args)
  31.    local in_list, to_list, infile, tofile, colors, map, i
  32.  
  33.    in_list := args[1] | stop("*** no input list specified")
  34.    to_list := args[2] | stop("*** no map list specified")
  35.  
  36.    infile := dopen(in_list) | stop("*** cannot open ", in_list)
  37.    tofile := dopen(to_list) | stop("*** cannot open ", to_list)
  38.  
  39.    in_list := []
  40.    write(read(infile))            # header
  41.    while put(in_list, read(infile))
  42.    to_list := []
  43.    while put(to_list, read(tofile))
  44.  
  45.    colors := table(0)
  46.    every colors[!in_list] +:= 1
  47.    colors := sort(colors, 4)
  48.    map := table()
  49.    every i := 1 to *colors / 2 do {
  50.       pull(colors)
  51.       map[pull(colors)] := i
  52.       }
  53.  
  54.    xdump(colors)
  55.    xdump(map)
  56.  
  57. end
  58.