Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: cross-product array function?
On Tue, Feb 03, 1998 at 03:59:44PM -0500, Nate Johnston wrote:
> On Tue, 3 Feb 1998, Andrew Main wrote:
>
> #foo=(first second third)
> #bar=(word person base)
> #echo $^foo$^bar
>
> I attempted this, and I had an odd result on the first element of the
> first array. Is this broken in the version I use?
>
> natej:~> ONE=(1 2 3)
> natej:~> TWO=(A B C)
> natej:~> echo $^ONE$^TWO
> 1C 2A 2B 2C 3A 3B 3C
>
> zsh: 3.0.0
i get this behaviour too, with 3.1.2.
even stranger is what happens with more than two items variables being
expanded; the behaviour is the same if i use the $^ shortcut. i was expecting
the output to be
1AZ 1BX 1BY 1BZ 1CX 1CY 1CZ 2AX 2AY 2AZ 2BX 2BY 2BZ 2CX 2CY 2CZ 3AX 3AY 3AZ 3BX
3BY 3BZ 3CX 3CY 3CZ
, where all of the elements of the first expansion were lost but the
last one, or perhaps
1CZ 2AX 2AY 2AZ 2BX 2BY 2BZ 2CX 2CY 2CZ 3AX 3AY 3AZ 3BX 3BY 3BZ 3CX 3CY 3CZ
(depending on if the expansion were recursive or not). if everything
were working okay, i would have expected
1AX 1AY 1AZ 1BX 1BY 1BZ 1CX 1CY 1CZ 2AX 2AY 2AZ 2BX 2BY 2BZ 2CX 2CY 2CZ 3AX 3AY
3AZ 3BX 3BY 3BZ 3CX 3CY 3CZ
but instead, there is this very strange output:
$ foo=(1 2 3)
$ bar=(A B C)
$ mug=(X Y Z)
$ setopt rcexpandparam
$ echo ${foo}${bar}${mug}
1CZ 2AZ 2BX 2BY 2BZ 2CX 2CY 2CZ 3AZ 3BX 3BY 3BZ 3CX 3CY 3CZ
is this a bug? feature? gross network error somewhere between the chair
and the keyboard?
--
"Countin' on a remedy I've counted on before
Goin' with a cure that's never failed me
What you call the disease
I call the remedy" -- The Mighty Mighty Bosstones
Messages sorted by:
Reverse Date,
Date,
Thread,
Author