develooper Front page | perl.perl6.language | Postings from February 2005

Re: Fwd: Junctive puzzles.

Thread Previous | Thread Next
From:
Patrick R. Michaud
Date:
February 10, 2005 06:20
Subject:
Re: Fwd: Junctive puzzles.
Message ID:
20050210141944.GC12141@pmichaud.com
On Thu, Feb 10, 2005 at 10:42:34AM +0000, Thomas Yandell wrote:
> Is the following comment correct?
> 
> my $x = any(2,3,4,5) and any(4,5,6,7); # $x now contains any(4,5)

Short answer:  I don't think so.

Long answer: I tend to get very lost when dealing with junctions, so 
I can be completely wrong.  However, watch the precedence and meanings 
of the operators here -- I would think that

   my $x = any(2,3,4,5) and any(4,5,6,7); 

results in $x containing any(2,3,4,5), just as

   my $y = 2 and 3;

results in $y containing 2 (since C<and> has lower precedence than C<=>).

Even if you fixed the =/and precedence with parens, to read

   my $x = (any(2,3,4,5) and any(4,5,6,7));

then I think the result is still that $x contains any(4,5,6,7).
It gets interpreted as (from S09):

   $x = any(  2 and 4,       # 4
              2 and 5,       # 5
              2 and 6,       # 6
              2 and 7,       # 7
              3 and 4,       # 4
              3 and 5,       # 5
              # etc...
              5 and 6,       # 6
              5 and 7,       # 7
           );

which ultimately boils down to any(4,5,6,7).

Pm

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About