On 2019-12-09 13:30, Tobias Boege wrote:
On Mon, 09 Dec 2019, perl6-users-h...@perl.org wrote:
Date: Sun, 8 Dec 2019 17:45:22 -0800
From: ToddAndMargo via perl6-users <perl6-us...@perl.org>
To: perl6-users <perl6-us...@perl.org>
Subject: My keeper on "contains"

8< ...

Case insensitive contains:
     $ p6 'if "2018 Jul 7".fc.contains( "jul".fc ) {say "Yes";}'
     Yes

     $ p6 'if "2018 xJul 7".fc.contains( "jul".fc ) {say "Yes";}'
     Yes

     p6 'if "2018 xul 7".fc.contains( "jul".fc ) {say "Yes";}'
     <nothing>

     $ p6 'my $x="strong>2018.2.0; Coming Soon</strong>"; say so $x.fc.contains("strong" 
& not "coming soon");'
     False


Careful about the last example, it is misleading. The `not` in
`"strong" & not "coming soon"` is not a junction constructor but
is evaluated eagerly, resulting in this junction:

   $ rk 'dd "strong" & not "coming soon"'
   all("strong", Bool::False)

because not("coming soon") is False at the moment where the &
operator assembles the all-junction. The result of passing this
to .contains will always be False, e.g.

   $ rk 'say so "strong".contains("strong" & not "weak")'
   False

What you meant was

   $ rk 'say so "strong".contains("strong" & none "weak")'
   True

which sadly doesn't sound as natural in English.

Regards,
Tobias

PS: Sorry for not replying in-thread. I just registered and didn't have
a proper copy of the mail at hand. (When I read about the "get" command
of the mailing list manager, I got my hopes up too high apparently as I
just received the mail canned in a digest, not suitable for replying.)


Hi Tobias,

No problem!  Thank you for replying however you did it!

I will post back when I revise for the booboo you pointed out.
Thank you!

-T

Peer review.  It's a good thing.  :-)

Reply via email to