On Wed, Dec 19, 2018 at 04:14:37AM -0800, ToddAndMargo via perl6-users wrote: > > > Le mer. 19 déc. 2018 à 08:57, ToddAndMargo via perl6-users > > > <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> a écrit : > > > > > > >> On Tue, Dec 18, 2018 at 10:49 PM ToddAndMargo via perl6-users > > > >> <perl6-us...@perl.org <mailto:perl6-us...@perl.org> > > > <mailto:perl6-us...@perl.org <mailto:perl6-us...@perl.org>>> wrote: > > > >> > > > >> Hi All, > > > >> > > > >> Where is my booboo? > > > >> > > > >> $ p6 'my$x="abcd"; if $x.contains("b" && not "q") {say > > > "y"}else{say > > > >> "n"};' > > > >> > > > >> n > > > >> > > > >> > > > >> In the mean time, I will ue > > > >> if $x.contains("b") && not $x.contains( "q" ) > > > >> > > > >> > > > >> Many thanks, > > > >> -T > > > > > > On 12/18/18 4:13 PM, Ralph Mellor wrote: > > > > .contains tests whether its invocant, treated as a string, > > > contains its > > > > argument, treated as a string. > > > > > > > > The argument you've given to .contains is: > > > > > > > > "b" && not "q". > > > > > > > > That's not a string. > > > > > > > > Here's one option: > > > > > > > > my$x="abcd"; if $x.contains("b") && not $x.contains("q") {say > > > > "y"}else{say "n"}; > > > > > > > > > > Hi Ralph, > > > > > > That was my work around. > > > > > > The reason I asked the question was the following: > > > > > > $ p6 'my$x="abcd"; if $x.contains("b" & "d") {say "y"}else{say "n"};' > > > y > > > > > > $ p6 'my$x="abcd"; if $x.contains("b" & "e") {say "y"}else{say "n"};' > > > n > > > > > > So it seemed to me that the following should also work, which > > > it does not: > > > > > > Should be "y" > > > $ p6 'my$x="abcd"; if $x.contains("b" & not "e") {say "y"}else{say > > > "n"};' > > > n > > > > > > Should be "n" and it is > > > $ p6 'my$x="abcd"; if $x.contains("b" & not "d") {say "y"}else{say > > > "n"};' > > > n > > > > > > > > > I think maybe I am pushing the limits. Perl has 101 way of > > > doing everything. It think I am pushing 102. > > > > > > -T > > > > > On 12/19/18 12:37 AM, Laurent Rosenfeld via perl6-users wrote: > > Hi Todd, > > > > first, please don't mix up the && Boolean operator and infix &, an /all/ > > junction operator. > > > > Also consider the difference between the following code snippets: > > > > > my$x="abcd"; if $x.contains(not "e") {say "y"}else{say "n"}; > > n > > > my$x="abcd"; if $x.contains(none "e") {say "y"}else{say "n"}; > > y > > > > Or between these: > > > > > my$x="abcd"; if $x.contains("b" & (not "d")) {say "y"}else{say "n"}; > > n > > > my$x="abcd"; if $x.contains("b" & (none "e")) {say "y"}else{say "n"}; > > y > > > > HTH, Laurent. > > "none" sweet. I did not know I could do that. Thank you! > Got to get my "not"'s straightened out too.
Please note that the difference between "none" and "not" is exactly the same as the difference between "&" and "&&" - one is a junction operator (BTW let me just say "sweet!" and thank the Perl 6 gods for bringing this to us!) and the other is a Boolean logical operator. G'luck, Peter -- Peter Pentchev roam@{ringlet.net,debian.org,FreeBSD.org} p...@storpool.com PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13
signature.asc
Description: PGP signature