Paul Hodges wrote:

--- David Christensen <[EMAIL PROTECTED]> wrote:


I'm looking in S09, and reading about junctions.  It seems to me
that if we have a junction $j which we use to index into an array
or a hash, it should DWIM and return a junction of the corresponding
values.

@ar=[1..10];
%hash=(a=>1,b=>4,c=>7);

$j=1|2|3;
$k="a"|"c";

$u = @ar[$j];       # 2|3|4
$v = %hash{$k}; # 1|7

Does this make sense to others?

David



Maybe, but I don't like returning junctures in those cases unless you *explicitly* ask for it. I'd rather the default be the arbitrary lists returned, or whatever fits the context. How about

@ar=[a..z];
%hash=(a=>1,b=>4,c=>7);

$j=1|2|3;
$k="a"|"c";

@u  = @ar[$j];            # (b..d)
%u  = @ar[$j].kv;         # (1=>'b',2=>'c',3=>'d')
$u  = @ar[$j];            # \(b..d)
$ju = juncture @ar[$j];   # 'b'|'c'|'d'

@v = %hash{$k}; # (1,7)
%v = %hash{$k}.kv; # (a=>1,c=>7) $v = %hash{$k}; # \(1,7)
$jv = juncture %hash{$k}; # 1|7


Am I way off base here?


What would you propose

   @v[all(any(4,5),one(1,2,3),none(7,8,9))]

return?

-- Rod Adams



Reply via email to