rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* list catenation question
@ 1991-08-27 17:15 Steve McConnel
  1991-08-27 17:55 ` list catenation question, and a plea for reading the archives John Mackin
  0 siblings, 1 reply; 2+ messages in thread
From: Steve McConnel @ 1991-08-27 17:15 UTC (permalink / raw)
  To: rc

Using rc 1.1gamma, the following operation acted like I expected:
	(./ /u/bin/)^(fixytab fixycode)
produces
	./fixytab /u/bin/fixycode
I'm not sure that I like pairwise expansion, but since it's documented,
I expected it.  However, the following operation surprised me:
	(. /u/bin)^/fixy^(tab code)
also produces
	./fixytab /u/bin/fixycode
Thinking about this, I guess it must be the correct behavior, but it was
a surprise!  I guess my experience with csh's and bash's {,,} lists has
corrupted my mental model of list expansions to expect cross products
rather than dot products. :-(  Is there any way to get a cross product
other than with a for loop?
--
Stephen McConnel                      UUCP: ...!{convex|utafll}!txsil!steve
Summer Institute of Linguistics   Internet: steve@txsil.sil.org
Dallas, Texas                          (or) steve@utafll.uta.edu


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: list catenation question, and a plea for reading the archives
  1991-08-27 17:15 list catenation question Steve McConnel
@ 1991-08-27 17:55 ` John Mackin
  0 siblings, 0 replies; 2+ messages in thread
From: John Mackin @ 1991-08-27 17:55 UTC (permalink / raw)
  To: The rc Mailing List

Steve McConnel asks:

    Is there any way to get a cross product other than with a for loop?

One of the reasons Boyd got annoyed with the rc list is that it is
beginning to rehash issues that have already been discussed.  First we
had people wondering about DEFAULTTOSH, and now we have cross products
_again_!  (Steve, the answer is a definite yes; see below.)  Byron:
can you please have a canned message that you send out to new list
subscribers that _seriously encourages_ them to ftp and read the list
archive before bringing things up on the list?  I am sure you tell them
that it exists, but I don't think that by itself is quite enough -- I
think we need to point out that many of these things have already been
thought through and dealt with, and that if they have further comments
to make they should be made in the light of the previous discussion.

Now, Steve, I quote from the other half of the Sydney rc Mafia, my
friend and Bridge-partner Solid Hogan.  Enjoy!

OK,
John.

From: David Hogan <dhog@cs.su.oz.au>
Date: Thu, 4 Jul 1991 03:48:41 -0500
To: Rc mailing list <rc@archone.tamu.edu>
Subject: Re: username expansion, gnu readline, and code bloat
In-Reply-To: <9107021725.AA00431@roycroft.adobe.com>
Message-Id: <9107041848.17532.out.babuz@cs.su.oz.au>

[...]

[Now we move on to cross products: ]

> needed it:  so far, twice since i switched to rc as my full-time shell.  (six
> months or so.)  wanted it: a dozen or so times more.  often i do an `{ls|egrep}
> or somesuch where ^^ would have been far more convenient.

Well, you could have used the following trick I just worked out:

; z1=(a b c d)
; z2=(x y z)
; eval echo $z1 ^ '^(' ^ $^z2 ^ ')'
ax ay az bx by bz cx cy cz dx dy dz

And what could be simpler but to wrap this up in a shell function where
it'll always be there, just when you need it?  (You can turn the string
returned into a list, but this is trivial).  Of course, this will break
if one of the lists contains strings with spaces in them.  If you are
worried about that you could always use a single for loop, as follows:

foo=()
for (i in $z1) foo = ( $foo $i ^ $z2 )

You see, rc doesn't need built in cross products.

[...]


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1991-08-27 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-08-27 17:15 list catenation question Steve McConnel
1991-08-27 17:55 ` list catenation question, and a plea for reading the archives John Mackin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).