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

  1. ############################################################################
  2. #
  3. #    File:     everycat.icn
  4. #
  5. #    Subject:  Procedure for generating all concatenations
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     April 25, 1992
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #   everycat(x1, x2, ...) generates the concatenation of every string
  18. #   from !x1, !x2, ... .
  19. #
  20. #   For example, if
  21. #
  22. #    first := ["Mary", "Joe", "Sandra"]
  23. #    last := ["Smith", "Roberts"]
  24. #
  25. #   then
  26. #
  27. #    every write(everycat(first, " ", last))
  28. #
  29. #   writes
  30. #
  31. #    Mary Smith
  32. #    Mary Roberts
  33. #    Joe Smith
  34. #    Joe Roberts
  35. #    Sandra Smith
  36. #    Sandra Roberts
  37. #
  38. #  Note that x1, x2, ... can be any values for which !x1, !x2, ... produce
  39. #  strings or values convertible to strings.  In particular, in the example
  40. #  above, the second argument is a one-character string " ", so that !" "
  41. #  generates a single blank.
  42. #
  43. ############################################################################
  44.  
  45. procedure everycat(args[])
  46.    local arg
  47.  
  48.    arg := get(args) | fail
  49.  
  50.    if *args = 0 then
  51.       suspend !arg
  52.    else
  53.       suspend !arg || everycat ! args
  54.  
  55. end
  56.