summaryrefslogtreecommitdiff
path: root/ipl/procs/everycat.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/procs/everycat.icn')
-rw-r--r--ipl/procs/everycat.icn55
1 files changed, 55 insertions, 0 deletions
diff --git a/ipl/procs/everycat.icn b/ipl/procs/everycat.icn
new file mode 100644
index 0000000..1ecbe73
--- /dev/null
+++ b/ipl/procs/everycat.icn
@@ -0,0 +1,55 @@
+############################################################################
+#
+# File: everycat.icn
+#
+# Subject: Procedure for generating all concatenations
+#
+# Author: Ralph E. Griswold
+#
+# Date: April 25, 1992
+#
+############################################################################
+#
+# This file is in the public domain.
+#
+############################################################################
+#
+# everycat(x1, x2, ...) generates the concatenation of every string
+# from !x1, !x2, ... .
+#
+# For example, if
+#
+# first := ["Mary", "Joe", "Sandra"]
+# last := ["Smith", "Roberts"]
+#
+# then
+#
+# every write(everycat(first, " ", last))
+#
+# writes
+#
+# Mary Smith
+# Mary Roberts
+# Joe Smith
+# Joe Roberts
+# Sandra Smith
+# Sandra Roberts
+#
+# Note that x1, x2, ... can be any values for which !x1, !x2, ... produce
+# strings or values convertible to strings. In particular, in the example
+# above, the second argument is a one-character string " ", so that !" "
+# generates a single blank.
+#
+############################################################################
+
+procedure everycat(args[])
+ local arg
+
+ arg := get(args) | fail
+
+ if *args = 0 then
+ suspend !arg
+ else
+ suspend !arg || everycat ! args
+
+end