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

  1. ############################################################################
  2. #
  3. #    File:     kross.icn
  4. #
  5. #    Subject:  Program to show intersections of strings
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     May 9, 1989
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #     This program procedure accepts pairs of strings on successive lines.
  18. #  It diagrams all the intersections of the two strings in a common
  19. #  character.
  20. #
  21. ############################################################################
  22.  
  23. procedure main()
  24.    local line, j
  25.    while line := read() do {
  26.       kross(line,read())
  27.       }
  28. end
  29.  
  30. procedure kross(s1,s2)
  31.    local j, k
  32.    every j := upto(s2,s1) do
  33.       every k := upto(s1[j],s2) do
  34.          xprint(s1,s2,j,k)
  35. end
  36.  
  37. procedure xprint(s1,s2,j,k)
  38.    write()
  39.    every write(right(s2[1 to k-1],j))
  40.    write(s1)
  41.    every write(right(s2[k+1 to *s2],j))
  42. end
  43.