Re: .contains question

2023-12-11 Thread ToddAndMargo via perl6-users
On 12/11/23 14:47, Andy Bach wrote:  I have found that when using `say` for debugging, it has been known to print out the previous value of a variable and not the current value.  `print` does not do this. That would certainly be a surprise to me. I'd think I was misunderstanding my program,

Re: .contains question

2023-12-11 Thread Andy Bach
than a bug in say. From: ToddAndMargo via perl6-users Sent: Monday, December 11, 2023 3:24 PM To: perl6-users@perl.org Subject: Re: .contains question CAUTION - EXTERNAL: > "so" will collapse the junction into a Bool. > "say" will append a \

Re: .contains question

2023-12-11 Thread ToddAndMargo via perl6-users
"so" will collapse the junction into a Bool. "say" will append a \n for you, so you don't have to. On 11 Dec 2023, at 01:52, ToddAndMargo via perl6-users wrote: On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users wrote: Hi All, my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3

Re: .contains question

2023-12-11 Thread Elizabeth Mattijsen
my $x="abc45def"; my @y=; say so $x.contains(any @y); "so" will collapse the junction into a Bool. "say" will append a \n for you, so you don't have to. > On 11 Dec 2023, at 01:52, ToddAndMargo via perl6-users > wrote: > >>> On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users >>> wrote: >

Re: .contains question

2023-12-10 Thread ToddAndMargo via perl6-users
On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users wrote: Hi All, my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3" ) { print "True\n"; } else { print "False\n" }; True Is there a way to tell .contains that you want to know if any of a sequence characters is in a string other that

Re: .contains question

2023-12-10 Thread Elizabeth Mattijsen
my @letters = ; if $x.contains(any @letters) { ... > On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users > wrote: > > Hi All, > > my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3" ) { print "True\n"; > } else { print "False\n" }; > True > > Is there a way to tell .contains that yo

.contains question

2023-12-10 Thread ToddAndMargo via perl6-users
Hi All, my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3" ) { print "True\n"; } else { print "False\n" }; True Is there a way to tell .contains that you want to know if any of a sequence characters is in a string other that repeating || over and over. Any [a..z] or [0..9] option? Many

Re: contains question

2017-06-13 Thread Timo Paulssen
Yup, you can use it as a method call like this: perl6 -e '"foobar".&[~~](/foo/).say' 「foo」 HTH - Timo

Re: contains question

2017-06-13 Thread Julien Simonet
Semantically, is a Regex can be "contained" by a String? As Liz wrote, a regex is "matched" against a String. Besides that, I'm wondering if the smart match operator ~~ can be used as a method call? "foobar".smart-match( /'foo'/ ).say in place of ( "foobar" ~~ /'foo'/ ).say AFAIK, it exists t

Re: contains question

2017-06-12 Thread Will Coleda
On Mon, Jun 12, 2017 at 4:07 PM, Elizabeth Mattijsen wrote: >> On 12 Jun 2017, at 22:04, Will Coleda wrote: >> On Mon, Jun 12, 2017 at 5:17 AM, Francesco Rivetti wrote: >>> if you can: >>> >>> $s ~~ "foo" >>> $s ~~ /foo/ >>> >>> then wouldn't be good to have also: >>> >>> $s.contains("foo"); >>>

Re: contains question

2017-06-12 Thread Elizabeth Mattijsen
> On 12 Jun 2017, at 22:04, Will Coleda wrote: > On Mon, Jun 12, 2017 at 5:17 AM, Francesco Rivetti wrote: >> if you can: >> >> $s ~~ "foo" >> $s ~~ /foo/ >> >> then wouldn't be good to have also: >> >> $s.contains("foo"); >> $s.contains(/foo/); > > The latter is currently available as: > >>

Re: contains question

2017-06-12 Thread Will Coleda
On Mon, Jun 12, 2017 at 5:17 AM, Francesco Rivetti wrote: > if you can: > > $s ~~ "foo" > $s ~~ /foo/ > > then wouldn't be good to have also: > > $s.contains("foo"); > $s.contains(/foo/); The latter is currently available as: > "foobar".match(/'foo'/); 「foo」 > IOW, overload .contains() with St

Re: contains question

2017-06-12 Thread ToddAndMargo
On 06/12/2017 01:42 AM, Elizabeth Mattijsen wrote: On 12 Jun 2017, at 01:27, ToddAndMargo wrote: perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else {say "in"}' Would this be easier to do with $x.contains? Or would it be too worky? .contains only takes a *single string

Re: contains question

2017-06-12 Thread Elizabeth Mattijsen
Thinking about this... > On 12 Jun 2017, at 11:17, Francesco Rivetti wrote: > > if you can: > > $s ~~ "foo" > $s ~~ /foo/ > > then wouldn't be good to have also: > > $s.contains("foo"); > $s.contains(/foo/); > > IOW, overload .contains() with Str and Regex > > F > > On 06/12/2017 10:42 AM,

Re: contains question

2017-06-12 Thread Francesco Rivetti
if you can: $s ~~ "foo" $s ~~ /foo/ then wouldn't be good to have also: $s.contains("foo"); $s.contains(/foo/); IOW, overload .contains() with Str and Regex F On 06/12/2017 10:42 AM, Elizabeth Mattijsen wrote: On 12 Jun 2017, at 01:27, ToddAndMargo wrote: perl6 -e 'my $x = "\t"; if $x !~

Re: contains question

2017-06-12 Thread Elizabeth Mattijsen
> On 12 Jun 2017, at 01:27, ToddAndMargo wrote: > perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else {say > "in"}' > > Would this be easier to do with $x.contains? Or would it > be too worky? .contains only takes a *single string* to look up. So it is only useful for ch

contains question

2017-06-11 Thread ToddAndMargo
Hi All, perl6 -e 'my $x = "\t"; if $x !~~ /<[A..Z a..z 0..9]>/ {say "out"} else {say "in"}' Would this be easier to do with $x.contains? Or would it be too worky? Many thanks, -T