On Mon, 09 Dec 2019, [email protected] wrote:
> Date: Sun, 8 Dec 2019 17:45:22 -0800
> From: ToddAndMargo via perl6-users <[email protected]>
> To: perl6-users <[email protected]>
> 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.)
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk