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 / gprogs / xformpat.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  53 lines

  1. ############################################################################
  2. #
  3. #    File:     xformpat.icn
  4. #
  5. #    Subject:  Program to apply transformation to patterns
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     August 12, 1993
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program takes patterns from standard input and applies a
  18. #  transformation to each one, writing the results to standard output.
  19. #  The transformation to be applied is given in terms of command-line
  20. #  arguments, with the transformation first, followed by any arguments,
  21. #  as in
  22. #
  23. #    xformpat center 32 32
  24. #
  25. #  which would attempt to produce a 32x32 centered pattern from each
  26. #  pattern in standard input.
  27. #
  28. #  Warning:  Some transformations can fail.  In cae of failure, no
  29. #  pattern is written.
  30. #
  31. ############################################################################
  32. #
  33. #  Links:  patxform
  34. #
  35. ############################################################################
  36.  
  37. invocable all
  38.  
  39. link patxform
  40.  
  41. procedure main(args)
  42.    local xform, rows
  43.  
  44.    xform := proc("p" || args[1]) | stop("** invalid transformation")
  45.  
  46.    while rows := pat2rows(readpatt()) do {
  47.       get(args)            # a trick here; there's always an extra
  48.       push(args, rows)
  49.       write(rows2pat(xform ! args))
  50.       }
  51.  
  52. end
  53.