develooper Front page | perl.perl6.users | Postings from October 2019

Re: Match operator: error with any() junction and user-defined $_topic variable

Thread Previous | Thread Next
From:
William Michels via perl6-users
Date:
October 11, 2019 09:47
Subject:
Re: Match operator: error with any() junction and user-defined $_topic variable
Message ID:
CAA99HCyzW1X+j_ab6m0QgHx0YwLPXV+UZ0esYjRfFcCmE78PWg@mail.gmail.com
Below works:

mbook:~ homedir$ perl6 -e 'my $x = (44, 66); say $x; say $x.any < 43'
(44 66)
any(False, False)
#
mbook:~ homedir$ perl6 -e 'my $x = (44, 66); say $x; say $x.any < 50'
(44 66)
any(True, False)
#
mbook:~ homedir$ perl6 -e 'my $x=0; my $any=2|4|8; $x==$any ?? put "x
exists, value= $x" !! put "not there";'
not there
#
mbook:~ homedir$ perl6 -e 'my $x=4; my $any=2|4|8; $x==$any ?? put "x
exists, value= $x" !! put "not there";'
x exists, value= 4
#

HTH, Bill.

On Thu, Oct 10, 2019 at 9:30 PM Todd Chester via perl6-users
<perl6-users@perl.org> wrote:
>
>
>
> On 10/8/19 10:53 AM, Brad Gilbert wrote:
> > Most operations with Junctions produce Junctions.
> >
> >      > 1 + any(2, 3)
> >      any(3, 4)
>
> $ p6 'say 4 + any(44,66);'
> any(48, 70)
>
> Sweet!  But what would you ever use it for?
>
> Would this be the intended use: add a number to all
> values in an array?
>
> $ p6 'my @x=[44,66]; say 4 + @x.any;'
> any(48, 70)
>
> $ p6 'my @x=[44,66]; 4 + @x.any; say @x'
> WARNINGS for -e:
> Useless use of "+" in expression "4 + @x.any" in sink context (line 1)
> [44 66]
>
>
> -T

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