#### Learning the "ff" (flipflop) infix operator? (was Re: Raku version of "The top 10 tricks... .")

```Hello,

I'm trying to learn the "ff" (flipflop) infix operator, generally
taking examples from the docs (below):

https://docs.raku.org/routine/ff

output isn't what I expect with the "m:2nd" adverb (examples #3 and
#5):

say "\n1. ----";
for <AB C D B E F> {
say \$_ if /A/ ff /B/;  # OUTPUT: =C2=ABAB=E2=90=A4=C2=BB
}

say "\n2. ----";
#mine
for <AB C D B E F> {
say \$_ if /A/ ff m:1st/B/;  # OUTPUT: =C2=ABAB=E2=90=A4=C2=BB
}

say "\n3. ----";
#mine
for <AB C D B E F> {
say \$_ if /A/ ff m:2nd/B/;  # OUTPUT: =C2=ABAB=E2=90=A4C=E2=90=A4D=E2=
=90=A4B=E2=90=A4E=E2=90=A4F=E2=90=A4=C2=BB
}

say "\n4. ----";
for <AB C D B E F> {
say \$_ if /C/ ff *;    # OUTPUT: =C2=ABC=E2=90=A4D=E2=90=A4B=E2=90=A4E=
=E2=90=A4F=E2=90=A4=C2=BB
}

say "\n5. ----";
#mine
for <AB C D B E F> {
say \$_ if m:2nd/B/ ff *;    # OUTPUT: blank
}

I'm wondering if I'm using the correct "flipflop" operator, since
"ff", "ff^", "fff", and "fff^" are all provided in Raku.

Any assistance appreciated, Bill.
```
 0
perl6
7/25/2020 8:16:06 PM
perl.perl6.users 1447 articles. 0 followers.

10 Replies
25 Views

Similar Articles

[PageSpeed] 52

```--000000000000ace79105ab4ad244
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

There's the ff operator and the fff operator.

The ff operator allows both endpoints to match at the same time.
The fff operator doesn't.

On Sat, Jul 25, 2020 at 3:16 PM William Michels via perl6-users <
perl6-users@perl.org> wrote:

> Hello,
>
> I'm trying to learn the "ff" (flipflop) infix operator, generally
> taking examples from the docs (below):
>
> https://docs.raku.org/routine/ff
>
> output isn't what I expect with the "m:2nd" adverb (examples #3 and
> #5):
>
> say "\n1. ----";
> for <AB C D B E F> {
>     say \$_ if /A/ ff /B/;  # OUTPUT: =C2=ABAB=E2=90=A4=C2=BB
> }
>

You should probably use the fff operator instead

for <AB C D B E F> {
say \$_ if /A/ fff /B/;  # OUTPUT: =C2=ABAB=E2=90=A4C=E2=90=A4D=E2=
=90=A4B=E2=90=A4=C2=BB
}

> say "\n2. ----";
> #mine
> for <AB C D B E F> {
>     say \$_ if /A/ ff m:1st/B/;  # OUTPUT: =C2=ABAB=E2=90=A4=C2=BB
> }
>

I don't know why you would think that :1st would work that way.
:1st doesn't really do anything.
It makes it so that it matches at the first occurrence, which is the
default anyway.

'ABcdeFB' ~~ m:1st/.B/; # =EF=BD=A2AB=EF=BD=A3
'ABcdeFB' ~~ m:2nd/.B/; # =EF=BD=A2FB=EF=BD=A3

The /.B/ can match in two different places in the string, :1st makes it so
that it matches the first occurrence.
:2nd makes it match the second occurence.

At any rate it doesn't do anything special when used as part of a ff
operator.

If you wanted the 'B' to match at the first position, you need to indicate
that.
Generally you would use `^` for beginning of string.

say \$_ if /A/ ff /^B/; # OUTPUT: =C2=ABAB=E2=90=A4C=E2=90=A4D=E2=90=A4B=
=E2=90=A4=C2=BB

> say "\n3. ----";
> #mine
> for <AB C D B E F> {
>     say \$_ if /A/ ff m:2nd/B/;  # OUTPUT: =C2=ABAB=E2=90=A4C=E2=90=A4D=E2=
=90=A4B=E2=90=A4E=E2=90=A4F=E2=90=A4=C2=BB
> }

None of those strings can match 'B' more than once, so m:2nd/B/ will always
fail.
Which means that the ff operator will not stop.

> say "\n4. ----";
> for <AB C D B E F> {
>     say \$_ if /C/ ff *;    # OUTPUT: =C2=ABC=E2=90=A4D=E2=90=A4B=E2=90=A4=
E=E2=90=A4F=E2=90=A4=C2=BB
> }
>

Generally * matches everything.
In this case if it is on the right side of ff, it actually means don't stop=
..
(If it were on the left it would mean always start)

say "\n5. ----";
> #mine
> for <AB C D B E F> {
>     say \$_ if m:2nd/B/ ff *;    # OUTPUT: blank
> }
>

Again there is nothing for :2nd to match, so it never does.

I'm wondering if I'm using the correct "flipflop" operator, since
> "ff", "ff^", "fff", and "fff^" are all provided in Raku.
>

I will say that fff is slightly easier to understand, but your real failure
to understand seems to be with :2nd.

Anyway it is intended to be more like:

for < A B start C D E F end G H I J start K L M N O end P Q R S T U V W
X Y Z > {
.say if "start" fff "end";
}
start
C
D
E
F
end
start
K
L
M
N
O
end

If you want to ignore the "start" you can use ^fff
If you want to ignore the "end" you can use fff^
If you want to ignore both use ^fff^

Same for ff  ( ^ff  ff^  ^ff^ )
And for .. ( ^..  ..^  ^..^ )

for < A B start C D E F end G H I J start K L M N O end P Q R S T U V W
X Y Z > {
.say if "start" ^fff^ "end";
}
C
D
E
F
K
L
M
N
O

In the above two cases ff and fff would behave identically.

The difference shines when the beginning marker can look like the end
marker.

for 1..20 {
.say if * %% 3 ff * %% 3
}
3 # matches both endpoints
6 # ditto
9
12
15
18

for 1..20 {
.say if * %% 3 fff * %% 3
}
3 # matches beginning (left)
4
5
6 # matches ending (right)
9 # begin
10
11
12 # end
15 # begin
16
17
18 # end

Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">There&#39;s the ff operator and the fff o=
perator.<div><br></div><div>The ff operator allows both endpoints to match =
at the same=C2=A0time.</div><div>The fff operator doesn&#39;t.</div></div><=
br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat,=
Jul 25, 2020 at 3:16 PM William Michels via perl6-users &lt;<a href=3D"mai=
lto:perl6-users@perl.org">perl6-users@perl.org</a>&gt; wrote:<br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
<br>
I&#39;m trying to learn the &quot;ff&quot; (flipflop) infix operator, gener=
ally<br>
taking examples from the docs (below):<br>
<br>
<a href=3D"https://docs.raku.org/routine/ff" rel=3D"noreferrer" target=3D"_=
blank">https://docs.raku.org/routine/ff</a><br>
<br>
rb, but the<br>
output isn&#39;t what I expect with the &quot;m:2nd&quot; adverb (examples =
#3 and<br>
#5):<br>
<br>
say &quot;\n1. ----&quot;;<br>
for &lt;AB C D B E F&gt; {<br>
=C2=A0 =C2=A0 say \$_ if /A/ ff /B/;=C2=A0 # OUTPUT: =C2=ABAB=E2=90=A4=C2=BB=
<br>
}<br></blockquote><div><br></div><div>You should probably use the fff opera=
tor instead</div><div><br></div><div>=C2=A0 =C2=A0 for &lt;AB C D B E F&gt;=
{<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 say \$_ if /A/ fff /B/;=C2=A0 # OUTPUT: =
=C2=ABAB=E2=90=A4C=E2=90=A4D=E2=90=A4B=E2=90=A4=C2=BB<br>=C2=A0 =C2=A0 }<br=
></div><div>=C2=A0<br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x">
say &quot;\n2. ----&quot;;<br>
#mine<br>
for &lt;AB C D B E F&gt; {<br>
=C2=A0 =C2=A0 say \$_ if /A/ ff m:1st/B/;=C2=A0 # OUTPUT: =C2=ABAB=E2=90=A4=
=C2=BB<br>
}<br></blockquote><div><br></div><div>I don&#39;t know why you would think =
that :1st would work that way.</div><div>:1st doesn&#39;t really do anythin=
g.</div><div>It makes it so that it matches at the first occurrence, which =
is the default anyway.</div><div><br></div><div>=C2=A0 =C2=A0 &#39;ABcdeFB&=
#39; ~~ m:1st/.B/; # =EF=BD=A2AB=EF=BD=A3</div><div>=C2=A0 =C2=A0 &#39;ABcd=
eFB&#39; ~~ m:2nd/.B/; # =EF=BD=A2FB=EF=BD=A3<br></div><div><br></div><div>=
The /.B/ can match in two different places in the string, :1st makes it so =
that it matches the first occurrence.</div><div>:2nd makes it match the sec=
ond occurence.</div><div><br></div><div>At any rate it doesn&#39;t do anyth=
ing special when used as part of a ff operator.</div><div><br></div><div>If=
you wanted the &#39;B&#39; to match at the first position, you need to ind=
icate that.</div><div>Generally you would use `^` for beginning of string.<=
/div><div><br></div><div>=C2=A0 =C2=A0 say \$_ if /A/ ff /^B/;=C2=A0# OUTPUT=
: =C2=ABAB=E2=90=A4C=E2=90=A4D=E2=90=A4B=E2=90=A4=C2=BB<br></div><div>=C2=
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
say &quot;\n3. ----&quot;;<br>
#mine<br>
for &lt;AB C D B E F&gt; {<br>
=C2=A0 =C2=A0 say \$_ if /A/ ff m:2nd/B/;=C2=A0 # OUTPUT: =C2=ABAB=E2=90=A4C=
=E2=90=A4D=E2=90=A4B=E2=90=A4E=E2=90=A4F=E2=90=A4=C2=BB<br>
}</blockquote><div><br></div><div>None of those strings can match &#39;B&#3=
9; more than once, so m:2nd/B/ will always fail.</div><div>Which means that=
the ff operator will not stop.</div><div>=C2=A0</div><blockquote class=3D"=
gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(20=
say &quot;\n4. ----&quot;;<br>
for &lt;AB C D B E F&gt; {<br>
=C2=A0 =C2=A0 say \$_ if /C/ ff *;=C2=A0 =C2=A0 # OUTPUT: =C2=ABC=E2=90=A4D=
=E2=90=A4B=E2=90=A4E=E2=90=A4F=E2=90=A4=C2=BB<br>
}<br></blockquote><div><br></div><div>Generally * matches everything.</div>=
<div>In this case if it is on the right side of ff, it actually means don&#=
39;t stop.</div><div>(If it were on the left it would mean always start)</d=
iv><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px=
say &quot;\n5. ----&quot;;<br>
#mine<br>
for &lt;AB C D B E F&gt; {<br>
=C2=A0 =C2=A0 say \$_ if m:2nd/B/ ff *;=C2=A0 =C2=A0 # OUTPUT: blank<br>
}<br></blockquote><div><br></div><div>Again there is nothing for :2nd to ma=
tch, so it never does.</div><div><br></div><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
I&#39;m wondering if I&#39;m using the correct &quot;flipflop&quot; operato=
r, since<br>
&quot;ff&quot;, &quot;ff^&quot;, &quot;fff&quot;, and &quot;fff^&quot; are =
all provided in Raku.<br></blockquote><div><br></div><div>I will say that f=
ff is slightly easier to understand, but your real failure to understand se=
ems to be with :2nd.</div><div><br></div><div><br></div><div>Anyway it is i=
ntended to be more like:</div><div><br></div><div>=C2=A0 =C2=A0 for &lt; A =
B start C D E F end G H I J start K L M N O end P Q R S T U=C2=A0V W X Y=C2=
=A0Z &gt; {</div><div>=C2=A0 =C2=A0 =C2=A0 .say if &quot;start&quot; fff &q=
uot;end&quot;;</div><div>=C2=A0 =C2=A0 }</div><div>=C2=A0 =C2=A0 start</div=
>=C2=A0 =C2=A0 C<br>=C2=A0 =C2=A0 D<br>=C2=A0 =C2=A0 E<br>=C2=A0 =C2=A0 F<b=
r>=C2=A0 =C2=A0 end<br>=C2=A0 =C2=A0 start<br>=C2=A0 =C2=A0 K<br>=C2=A0 =C2=
=A0 L<br>=C2=A0 =C2=A0 M<br>=C2=A0 =C2=A0 N<br>=C2=A0 =C2=A0 O<br>=C2=A0 =
=C2=A0 end<br><div><br></div><div>If you want to ignore the &quot;start&quo=
t; you can use ^fff</div><div>If you want to ignore the &quot;end&quot; you=
can use fff^</div><div>If you want to ignore both use ^fff^</div><div><br>=
</div><div>Same for ff=C2=A0 ( ^ff=C2=A0 ff^=C2=A0 ^ff^ )</div><div>And for=
.. ( ^..=C2=A0 ..^=C2=A0 ^..^ )</div><br>=C2=A0 =C2=A0 for &lt; A B start =
C D E F end G H I J start K L M N O end P Q R S T U=C2=A0V W X Y=C2=A0Z &gt=
; {<br>=C2=A0 =C2=A0 =C2=A0 .say if &quot;start&quot; ^fff^ &quot;end&quot;=
;<br>=C2=A0 =C2=A0 }<br>=C2=A0 =C2=A0 C<br>=C2=A0 =C2=A0 D<br>=C2=A0 =C2=A0=
E<br>=C2=A0 =C2=A0 F<br>=C2=A0 =C2=A0 K<br>=C2=A0 =C2=A0 L<br>=C2=A0 =C2=
=A0 M<br>=C2=A0 =C2=A0 N<br>=C2=A0 =C2=A0 O</div><div class=3D"gmail_quote"=
><br></div><div class=3D"gmail_quote">In the above two cases ff and fff wou=
ld behave identically.</div><div class=3D"gmail_quote"><br></div><div class=
=3D"gmail_quote">The difference shines when the beginning=C2=A0marker can l=
ook like the end marker.</div><div class=3D"gmail_quote"><br></div><div cla=
ss=3D"gmail_quote">=C2=A0 =C2=A0 for 1..20 {</div><div class=3D"gmail_quote=
">=C2=A0 =C2=A0 =C2=A0 .say if * %% 3 ff * %% 3</div><div class=3D"gmail_qu=
ote">=C2=A0 =C2=A0 }</div><div class=3D"gmail_quote">=C2=A0 =C2=A0 3 # matc=
hes both endpoints</div>=C2=A0 =C2=A0 6 # ditto<br>=C2=A0 =C2=A0 9<br>=C2=
=A0 =C2=A0 12<br>=C2=A0 =C2=A0 15<br>=C2=A0 =C2=A0 18<div><br><div>=C2=A0 =
=C2=A0 for 1..20 {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 .say if * %% 3 fff=
* %% 3</div><div>=C2=A0 =C2=A0 }<br>=C2=A0 =C2=A0 3 # matches beginning (l=
eft)<br>=C2=A0 =C2=A0 4<br>=C2=A0 =C2=A0 5<br>=C2=A0 =C2=A0 6 # matches end=
ing (right)<br>=C2=A0 =C2=A0 9 # begin<br>=C2=A0 =C2=A0 10<br>=C2=A0 =C2=A0=
11<br>=C2=A0 =C2=A0 12 # end<br>=C2=A0 =C2=A0 15 # begin<br>=C2=A0 =C2=A0 =
16<br>=C2=A0 =C2=A0 17<br>=C2=A0 =C2=A0 18 # end<br></div><div><br></div></=
div></div>

```
 0
b2gills
7/25/2020 9:32:02 PM
```On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
: In the above two cases ff and fff would behave identically.
:
: The difference shines when the beginning marker can look like the end
: marker.

The way I think of it is this:  You come to the end of "ff" sooner, so you
do the end test immediately after passing the start test.  You come to the
end of "fff" later, so the end test is delayed to the next iteration from
the start test.  (Same mnemonic for .. and ... in Perl, by the way, since
ff and fff were modeled on .. and ... (in their scalar form), but we stole
... and ... in Raku for ranges and sequences so we needed something else.)

I suppose if you're musical you can come up with mnemonics based on "fff"
being louder than "ff", so it echoes longer before it stops...  :)

Larry
```
 0
larry
7/26/2020 5:04:31 PM
```Thank you, Brad and Larry, for explaining the "ff" and "fff" infix
operators in Raku to me!

I have to admit that I'm still fuzzy on the particulars between "ff"
and "fff", since I am not familiar with the sed function. I can
certainly understand how useful these functions could be to 'pull out
all PGP signatures' from a file (which was the Perl5 example given in
the Oracle Linux Blog). So I can now  pull out the html "head" section
from the page _ https://raku.org/fun/ _ (saved locally as file
"fun.txt") using the following Raku code:

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Raku is optimized for fun!</title>

user@mbook:~\$

What I'm less clear on is how the code below is functioning. I first
print out file named "startling.txt" with 'cat':  it's supposed to
stand in for a text delimited linewise by "header 1", "header 2", etc.
After the 'cat' example, I show three examples with Perl(v5.26.3) and
three examples with Raku(2020.06), generally comparing literal vs
regex arguments.

The first two Perl5 examples returns nothing; the third Perl5 example
returns everything after the "star" line. For the Raku code, the
'DWIMmiest' output below is the first Raku example, which returns two
lines, "star" and "start". This is what I expected/desired. But I'm
not really understanding what's happening with the other 2 Raku
examples (which return everything after the "star" line):

user@mbook:~\$ cat startling.txt
s
st
sta
star
start
startl
startli
startlin
startling

user@mbook:~\$ perl -nE 'print if "star" .. "start" ;' startling.txt
user@mbook:~\$ perl -nE 'print if /"star"/ .. /"start"/ ;' startling.txt
user@mbook:~\$ perl -nE 'print if /star/ .. /start/ ;' startling.txt
star
start
startl
startli
startlin
startling
user@mbook:~\$ raku -ne '.put if "star" ff "start" ;' startling.txt
star
start
user@mbook:~\$ raku -ne '.put if /"star"/ ff /"start"/ ;' startling.txt
star
start
startl
startli
startlin
startling
user@mbook:~\$ raku -ne '.put if /star/ ff /start/ ;' startling.txt
star
start
startl
startli
startlin
startling
user@mbook:~\$

I'm all in favor of improving the "ff" and "fff" functions in Raku
over their Perl5 counterparts, but I'm hoping to gain a better
(mnemonic?) way of remembering the expected return values with literal
vs regex arguments.

Any assistance appreciated, Bill.

On Sun, Jul 26, 2020 at 10:04 AM Larry Wall <larry@wall.org> wrote:
>
> On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
> : In the above two cases ff and fff would behave identically.
> :
> : The difference shines when the beginning marker can look like the end
> : marker.
>
> The way I think of it is this:  You come to the end of "ff" sooner, so you
> do the end test immediately after passing the start test.  You come to the
> end of "fff" later, so the end test is delayed to the next iteration from
> the start test.  (Same mnemonic for .. and ... in Perl, by the way, since
> ff and fff were modeled on .. and ... (in their scalar form), but we stole
> .. and ... in Raku for ranges and sequences so we needed something else.)
>
> I suppose if you're musical you can come up with mnemonics based on "fff"
> being louder than "ff", so it echoes longer before it stops...  :)
>
> Larry
```
 0
perl6
7/28/2020 6:43:08 PM
```--0000000000009f243305ab88873a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

A regex doesn't have to match the entire string.

'abcd' ~~ / bc /
# =EF=BD=A2bc=EF=BD=A3

A string has to match exactly with the smart-match. (`ff` and `fff` do
smart-match)

'abcd' ~~ 'bc' # False
'abcd' ~~ 'abcd' # True

A string inside of a regex only makes that a single atom, it does not make
it match like just a string.

'abcd' ~~ / 'bc' /
# =EF=BD=A2bc=EF=BD=A3

'aBaBaB' ~~ / aB+ /
=EF=BD=A2aB=EF=BD=A3

'aBaBaB' ~~ / "aB"+ /
=EF=BD=A2aBaBaB=EF=BD=A3

In fact a string inside of a regex doesn't do much more than square
brackets.

'aBaBaB' ~~ / [aB]+ /
=EF=BD=A2aBaBaB=EF=BD=A3

If you want the regex to match fully, add a beginning of string and end of
string marker.

'abcd' ~~ / ^ bc \$ /
# Nil

'abcd' ~~ / ^ abcd \$ /
# =EF=BD=A2abcd=EF=BD=A3

---

Since `ff` can begin and end at the same time, the following is turning on
and off at almost every iteration of the loop after it starts.

\$ raku -ne '.put if /star {print q[on ]}/ ff /start {print q[off ]}/ ;'
startling.txt
on star
on off start
on off startl
on off startli
on off startlin
on off startling

On Tue, Jul 28, 2020 at 1:43 PM William Michels <wjm1@caa.columbia.edu>
wrote:

> Thank you, Brad and Larry, for explaining the "ff" and "fff" infix
> operators in Raku to me!
>
> I have to admit that I'm still fuzzy on the particulars between "ff"
> and "fff", since I am not familiar with the sed function. I can
> certainly understand how useful these functions could be to 'pull out
> all PGP signatures' from a file (which was the Perl5 example given in
> the Oracle Linux Blog). So I can now  pull out the html "head" section
> from the page _ https://raku.org/fun/ _ (saved locally as file
> "fun.txt") using the following Raku code:
>
>     <meta charset=3D"utf-8">
>     <meta http-equiv=3D"X-UA-Compatible" content=3D"IE=3Dedge">
>     <meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-scal=
e=3D1">
>     <title>Raku is optimized for fun!</title>
>
>
>     <link href=3D"/favicon.ico" rel=3D"shortcut icon" type=3D"image/x-ico=
n">
et">
>
> user@mbook:~\$
>
> What I'm less clear on is how the code below is functioning. I first
> print out file named "startling.txt" with 'cat':  it's supposed to
> stand in for a text delimited linewise by "header 1", "header 2", etc.
> After the 'cat' example, I show three examples with Perl(v5.26.3) and
> three examples with Raku(2020.06), generally comparing literal vs
> regex arguments.
>
> The first two Perl5 examples returns nothing; the third Perl5 example
> returns everything after the "star" line. For the Raku code, the
> 'DWIMmiest' output below is the first Raku example, which returns two
> lines, "star" and "start". This is what I expected/desired. But I'm
> not really understanding what's happening with the other 2 Raku
> examples (which return everything after the "star" line):
>
> user@mbook:~\$ cat startling.txt
> s
> st
> sta
> star
> start
> startl
> startli
> startlin
> startling
>
> user@mbook:~\$ perl -nE 'print if "star" .. "start" ;' startling.txt
> user@mbook:~\$ perl -nE 'print if /"star"/ .. /"start"/ ;' startling.txt
> user@mbook:~\$ perl -nE 'print if /star/ .. /start/ ;' startling.txt
> star
> start
> startl
> startli
> startlin
> startling
> user@mbook:~\$ raku -ne '.put if "star" ff "start" ;' startling.txt
> star
> start
> user@mbook:~\$ raku -ne '.put if /"star"/ ff /"start"/ ;' startling.txt
> star
> start
> startl
> startli
> startlin
> startling
> user@mbook:~\$ raku -ne '.put if /star/ ff /start/ ;' startling.txt
> star
> start
> startl
> startli
> startlin
> startling
> user@mbook:~\$
>
> I'm all in favor of improving the "ff" and "fff" functions in Raku
> over their Perl5 counterparts, but I'm hoping to gain a better
> (mnemonic?) way of remembering the expected return values with literal
> vs regex arguments.
>
> Any assistance appreciated, Bill.
>
>
>
>
>
>
> On Sun, Jul 26, 2020 at 10:04 AM Larry Wall <larry@wall.org> wrote:
> >
> > On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
> > : In the above two cases ff and fff would behave identically.
> > :
> > : The difference shines when the beginning marker can look like the end
> > : marker.
> >
> > The way I think of it is this:  You come to the end of "ff" sooner, so
> you
> > do the end test immediately after passing the start test.  You come to
> the
> > end of "fff" later, so the end test is delayed to the next iteration fr=
om
> > the start test.  (Same mnemonic for .. and ... in Perl, by the way, sin=
ce
> > ff and fff were modeled on .. and ... (in their scalar form), but we
> stole
> > .. and ... in Raku for ranges and sequences so we needed something else=
..)
> >
> > I suppose if you're musical you can come up with mnemonics based on "ff=
f"
> > being louder than "ff", so it echoes longer before it stops...  :)
> >
> > Larry
>

--0000000000009f243305ab88873a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">A regex doesn&#39;t have to match the entire string.<div><=
br></div><div>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ / bc /</div><div>=C2=A0 =C2=
=A0 # =EF=BD=A2bc=EF=BD=A3</div><div><br></div><div>A string has to match e=
xactly with the smart-match. (`ff` and `fff` do smart-match)</div><div><br>=
</div><div>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;bc&#39; # False</div><div>=
=C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;abcd&#39; # True</div><div><br></div><=
div>A string inside of a regex only makes that a single atom, it does not m=
ake it match like just a string.</div><div><br>=C2=A0 =C2=A0 &#39;abcd&#39;=
~~ / &#39;bc&#39; /<br>=C2=A0 =C2=A0 # =EF=BD=A2bc=EF=BD=A3<br></div><div>=
<br></div><div>=C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / aB+ /</div><div>=
=C2=A0 =C2=A0 =EF=BD=A2aB=EF=BD=A3<br></div><div><br></div><div>=C2=A0 =C2=
=A0 =C2=A0&#39;aBaBaB&#39; ~~ / &quot;aB&quot;+ /</div><div>=C2=A0 =C2=A0 =
=EF=BD=A2aBaBaB=EF=BD=A3</div><div><br></div><div>In fact a string inside o=
f a regex doesn&#39;t do much more than square brackets.</div><div><br>=C2=
=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / [aB]+ /<br>=C2=A0 =C2=A0 =EF=BD=A2aB=
aBaB=EF=BD=A3<br></div><div><br></div><div>If you want the regex to match f=
ully, add a beginning of string and end of string marker.</div><div><br>=C2=
=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ bc \$ /<br>=C2=A0 =C2=A0 # Nil<br></div><br=
>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ abcd \$ /<div>=C2=A0 =C2=A0 # =EF=BD=A2=
abcd=EF=BD=A3</div><div><br></div><div>---</div><div><br></div><div>Since `=
ff` can begin and end at the same time, the following is turning on and off=
at almost every iteration of the loop after it starts.</div><div><br></div=
><div><div>=C2=A0 =C2=A0 \$ raku -ne &#39;.put if /star {print q[on ]}/ ff /=
start {print q[off ]}/ ;&#39; startling.txt <br>=C2=A0 =C2=A0 on star<br>=
=C2=A0 =C2=A0 on off start<br>=C2=A0 =C2=A0 on off startl<br>=C2=A0 =C2=A0 =
on off startli<br>=C2=A0 =C2=A0 on off startlin<br>=C2=A0 =C2=A0 on off sta=
rtling<br></div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr"=
class=3D"gmail_attr">On Tue, Jul 28, 2020 at 1:43 PM William Michels &lt;<=
a href=3D"mailto:wjm1@caa.columbia.edu">wjm1@caa.columbia.edu</a>&gt; wrote=
:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.=
d and Larry, for explaining the &quot;ff&quot; and &quot;fff&quot; infix<br=
>
operators in Raku to me!<br>
<br>
I have to admit that I&#39;m still fuzzy on the particulars between &quot;f=
f&quot;<br>
and &quot;fff&quot;, since I am not familiar with the sed function. I can<b=
r>
certainly understand how useful these functions could be to &#39;pull out<b=
r>
all PGP signatures&#39; from a file (which was the Perl5 example given in<b=
r>
the Oracle Linux Blog). So I can now=C2=A0 pull out the html &quot;head&quo=
t; section<br>
from the page _ <a href=3D"https://raku.org/fun/" rel=3D"noreferrer" target=
=3D"_blank">https://raku.org/fun/</a> _ (saved locally as file<br>
&quot;fun.txt&quot;) using the following Raku code:<br>
<br>
; fun.txt<br>
=C2=A0 =C2=A0 &lt;meta charset=3D&quot;utf-8&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;meta http-equiv=3D&quot;X-UA-Compatible&quot; content=3D&=
quot;IE=3Dedge&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;meta name=3D&quot;viewport&quot; content=3D&quot;width=3D=
device-width, initial-scale=3D1&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;title&gt;Raku is optimized for fun!&lt;/title&gt;<br>
<br>
<br>
icon&quot; type=3D&quot;image/x-icon&quot;&gt;<br>
rel=3D&quot;stylesheet&quot;&gt;<br>
quot; rel=3D&quot;stylesheet&quot;&gt;<br>
esheet&quot;&gt;<br>
<br>
user@mbook:~\$<br>
<br>
What I&#39;m less clear on is how the code below is functioning. I first<br=
>
print out file named &quot;startling.txt&quot; with &#39;cat&#39;:=C2=A0 it=
&#39;s supposed to<br>
r 2&quot;, etc.<br>
After the &#39;cat&#39; example, I show three examples with Perl(v5.26.3) a=
nd<br>
three examples with Raku(2020.06), generally comparing literal vs<br>
regex arguments.<br>
<br>
The first two Perl5 examples returns nothing; the third Perl5 example<br>
returns everything after the &quot;star&quot; line. For the Raku code, the<=
br>
&#39;DWIMmiest&#39; output below is the first Raku example, which returns t=
wo<br>
lines, &quot;star&quot; and &quot;start&quot;. This is what I expected/desi=
red. But I&#39;m<br>
not really understanding what&#39;s happening with the other 2 Raku<br>
examples (which return everything after the &quot;star&quot; line):<br>
<br>
user@mbook:~\$ cat startling.txt<br>
s<br>
st<br>
sta<br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
<br>
user@mbook:~\$ perl -nE &#39;print if &quot;star&quot; .. &quot;start&quot; =
;&#39; startling.txt<br>
user@mbook:~\$ perl -nE &#39;print if /&quot;star&quot;/ .. /&quot;start&quo=
t;/ ;&#39; startling.txt<br>
user@mbook:~\$ perl -nE &#39;print if /star/ .. /start/ ;&#39; startling.txt=
<br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
user@mbook:~\$ raku -ne &#39;.put if &quot;star&quot; ff &quot;start&quot; ;=
&#39; startling.txt<br>
star<br>
start<br>
user@mbook:~\$ raku -ne &#39;.put if /&quot;star&quot;/ ff /&quot;start&quot=
;/ ;&#39; startling.txt<br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
user@mbook:~\$ raku -ne &#39;.put if /star/ ff /start/ ;&#39; startling.txt<=
br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
user@mbook:~\$<br>
<br>
I&#39;m all in favor of improving the &quot;ff&quot; and &quot;fff&quot; fu=
nctions in Raku<br>
over their Perl5 counterparts, but I&#39;m hoping to gain a better<br>
(mnemonic?) way of remembering the expected return values with literal<br>
vs regex arguments.<br>
<br>
Any assistance appreciated, Bill.<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Sun, Jul 26, 2020 at 10:04 AM Larry Wall &lt;<a href=3D"mailto:larry@wal=
l.org" target=3D"_blank">larry@wall.org</a>&gt; wrote:<br>
&gt;<br>
&gt; On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:<br>
&gt; : In the above two cases ff and fff would behave identically.<br>
&gt; :<br>
&gt; : The difference shines when the beginning marker can look like the en=
d<br>
&gt; : marker.<br>
&gt;<br>
&gt; The way I think of it is this:=C2=A0 You come to the end of &quot;ff&q=
uot; sooner, so you<br>
&gt; do the end test immediately after passing the start test.=C2=A0 You co=
me to the<br>
&gt; end of &quot;fff&quot; later, so the end test is delayed to the next i=
teration from<br>
&gt; the start test.=C2=A0 (Same mnemonic for .. and ... in Perl, by the wa=
y, since<br>
&gt; ff and fff were modeled on .. and ... (in their scalar form), but we s=
tole<br>
&gt; .. and ... in Raku for ranges and sequences so we needed something els=
e.)<br>
&gt;<br>
&gt; I suppose if you&#39;re musical you can come up with mnemonics based o=
n &quot;fff&quot;<br>
&gt; being louder than &quot;ff&quot;, so it echoes longer before it stops.=
...=C2=A0 :)<br>
&gt;<br>
&gt; Larry<br>
</blockquote></div>

--0000000000009f243305ab88873a--
```
 0
b2gills
7/28/2020 11:09:08 PM
```--00000000000056534505abd8ec59
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This made me want to try a contrived puzzle, use 'fff' to show things
between a "start" and 2nd "mark" line. That is, print any line below not
marked with "!" at the start

\$ cat example.txt

!ignore me

Start

hi print me

yes!

Mark

still print me

Mark

!ignore this line

!this line too

Start

We're back!

Mark

Still here!

Start

haha that Start does nothing

going to end it now

Mark

!bye bye don't see me!

Let's see...ooh that was easy!!

raku -ne '.say if "Start" ff (\$_ eq "Mark" && ++\$ %% 2)' example.txt

That increments the anonymous state variable \$ and then checks if it is
divisible by 2, so that only every 2nd Mark returns True

Don't know if I'll ever need it, fun to have it.

-y

On Tue, Jul 28, 2020 at 7:09 PM Brad Gilbert <b2gills@gmail.com> wrote:

> A regex doesn't have to match the entire string.
>
>     'abcd' ~~ / bc /
>     # =EF=BD=A2bc=EF=BD=A3
>
> A string has to match exactly with the smart-match. (`ff` and `fff` do
> smart-match)
>
>     'abcd' ~~ 'bc' # False
>     'abcd' ~~ 'abcd' # True
>
> A string inside of a regex only makes that a single atom, it does not mak=
e
> it match like just a string.
>
>     'abcd' ~~ / 'bc' /
>     # =EF=BD=A2bc=EF=BD=A3
>
>      'aBaBaB' ~~ / aB+ /
>     =EF=BD=A2aB=EF=BD=A3
>
>      'aBaBaB' ~~ / "aB"+ /
>     =EF=BD=A2aBaBaB=EF=BD=A3
>
> In fact a string inside of a regex doesn't do much more than square
> brackets.
>
>      'aBaBaB' ~~ / [aB]+ /
>     =EF=BD=A2aBaBaB=EF=BD=A3
>
> If you want the regex to match fully, add a beginning of string and end o=
f
> string marker.
>
>     'abcd' ~~ / ^ bc \$ /
>     # Nil
>
>     'abcd' ~~ / ^ abcd \$ /
>     # =EF=BD=A2abcd=EF=BD=A3
>
> ---
>
> Since `ff` can begin and end at the same time, the following is turning o=
n
> and off at almost every iteration of the loop after it starts.
>
>     \$ raku -ne '.put if /star {print q[on ]}/ ff /start {print q[off ]}/
> ;' startling.txt
>     on star
>     on off start
>     on off startl
>     on off startli
>     on off startlin
>     on off startling
>
> On Tue, Jul 28, 2020 at 1:43 PM William Michels <wjm1@caa.columbia.edu>
> wrote:
>
>> Thank you, Brad and Larry, for explaining the "ff" and "fff" infix
>> operators in Raku to me!
>>
>> I have to admit that I'm still fuzzy on the particulars between "ff"
>> and "fff", since I am not familiar with the sed function. I can
>> certainly understand how useful these functions could be to 'pull out
>> all PGP signatures' from a file (which was the Perl5 example given in
>> the Oracle Linux Blog). So I can now  pull out the html "head" section
>> from the page _ https://raku.org/fun/ _ (saved locally as file
>> "fun.txt") using the following Raku code:
>>
>>     <meta charset=3D"utf-8">
>>     <meta http-equiv=3D"X-UA-Compatible" content=3D"IE=3Dedge">
>>     <meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-sca=
le=3D1">
>>     <title>Raku is optimized for fun!</title>
>>
>>
>>     <link href=3D"/favicon.ico" rel=3D"shortcut icon" type=3D"image/x-ic=
on">
eet">
>>
>> user@mbook:~\$
>>
>> What I'm less clear on is how the code below is functioning. I first
>> print out file named "startling.txt" with 'cat':  it's supposed to
>> stand in for a text delimited linewise by "header 1", "header 2", etc.
>> After the 'cat' example, I show three examples with Perl(v5.26.3) and
>> three examples with Raku(2020.06), generally comparing literal vs
>> regex arguments.
>>
>> The first two Perl5 examples returns nothing; the third Perl5 example
>> returns everything after the "star" line. For the Raku code, the
>> 'DWIMmiest' output below is the first Raku example, which returns two
>> lines, "star" and "start". This is what I expected/desired. But I'm
>> not really understanding what's happening with the other 2 Raku
>> examples (which return everything after the "star" line):
>>
>> user@mbook:~\$ cat startling.txt
>> s
>> st
>> sta
>> star
>> start
>> startl
>> startli
>> startlin
>> startling
>>
>> user@mbook:~\$ perl -nE 'print if "star" .. "start" ;' startling.txt
>> user@mbook:~\$ perl -nE 'print if /"star"/ .. /"start"/ ;' startling.txt
>> user@mbook:~\$ perl -nE 'print if /star/ .. /start/ ;' startling.txt
>> star
>> start
>> startl
>> startli
>> startlin
>> startling
>> user@mbook:~\$ raku -ne '.put if "star" ff "start" ;' startling.txt
>> star
>> start
>> user@mbook:~\$ raku -ne '.put if /"star"/ ff /"start"/ ;' startling.txt
>> star
>> start
>> startl
>> startli
>> startlin
>> startling
>> user@mbook:~\$ raku -ne '.put if /star/ ff /start/ ;' startling.txt
>> star
>> start
>> startl
>> startli
>> startlin
>> startling
>> user@mbook:~\$
>>
>> I'm all in favor of improving the "ff" and "fff" functions in Raku
>> over their Perl5 counterparts, but I'm hoping to gain a better
>> (mnemonic?) way of remembering the expected return values with literal
>> vs regex arguments.
>>
>> Any assistance appreciated, Bill.
>>
>>
>>
>>
>>
>>
>> On Sun, Jul 26, 2020 at 10:04 AM Larry Wall <larry@wall.org> wrote:
>> >
>> > On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
>> > : In the above two cases ff and fff would behave identically.
>> > :
>> > : The difference shines when the beginning marker can look like the en=
d
>> > : marker.
>> >
>> > The way I think of it is this:  You come to the end of "ff" sooner, so
>> you
>> > do the end test immediately after passing the start test.  You come to
>> the
>> > end of "fff" later, so the end test is delayed to the next iteration
>> from
>> > the start test.  (Same mnemonic for .. and ... in Perl, by the way,
>> since
>> > ff and fff were modeled on .. and ... (in their scalar form), but we
>> stole
>> > .. and ... in Raku for ranges and sequences so we needed something
>> else.)
>> >
>> > I suppose if you're musical you can come up with mnemonics based on
>> "fff"
>> > being louder than "ff", so it echoes longer before it stops...  :)
>> >
>> > Larry
>>
>

--00000000000056534505abd8ec59
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div di=
r=3D"ltr">This made me want to try a contrived puzzle, use &#39;fff&#39; to=
show things between a &quot;start&quot; and 2nd &quot;mark&quot; line. Tha=
t is, print any line below not marked with &quot;!&quot; at the start<div><=
br></div><div>\$ cat example.txt</div><div><p style=3D"margin:0px;font-stret=
ch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0=
,0)"><span style=3D"font-variant-ligatures:no-common-ligatures">!ignore me<=
/span></p><p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-he=
ight:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant=
-ligatures:no-common-ligatures">Start</span></p><p style=3D"margin:0px;font=
-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:r=
gb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-ligatures">hi pr=
int me</span></p><p style=3D"margin:0px;font-stretch:normal;font-size:11px;=
line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-=
variant-ligatures:no-common-ligatures">yes!</span></p><p style=3D"margin:0p=
x;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;c=
olor:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-ligatures"=
>Mark</span></p><p style=3D"margin:0px;font-stretch:normal;font-size:11px;l=
ine-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-v=
ariant-ligatures:no-common-ligatures">still print me</span></p><p style=3D"=
margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-famil=
y:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-l=
igatures">Mark</span></p><p style=3D"margin:0px;font-stretch:normal;font-si=
ze:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=
=3D"font-variant-ligatures:no-common-ligatures">!ignore this line</span></p=
><p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:norm=
al;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligature=
s:no-common-ligatures">!this line too</span></p><p style=3D"margin:0px;font=
-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:r=
gb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-ligatures">Start=
</span></p><p style=3D"margin:0px;font-stretch:normal;font-size:11px;line-h=
eight:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-varian=
t-ligatures:no-common-ligatures">We&#39;re back!</span></p><p style=3D"marg=
in:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Me=
nlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-ligat=
ures">Mark</span></p><p style=3D"margin:0px;font-stretch:normal;font-size:1=
1px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"f=
ont-variant-ligatures:no-common-ligatures">Still here!</span></p><p style=
=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-f=
amily:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-comm=
on-ligatures">Start</span></p><p style=3D"margin:0px;font-stretch:normal;fo=
nt-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span s=
tyle=3D"font-variant-ligatures:no-common-ligatures">haha that Start does no=
thing</span></p><p style=3D"margin:0px;font-stretch:normal;font-size:11px;l=
ine-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style=3D"font-v=
ariant-ligatures:no-common-ligatures">going to end it now</span></p><p styl=
e=3D"margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-=
family:Menlo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-com=
mon-ligatures">Mark</span></p><p style=3D"margin:0px;font-stretch:normal;fo=
nt-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span s=
tyle=3D"font-variant-ligatures:no-common-ligatures">!bye bye don&#39;t see =
me!</span></p></div><div><span style=3D"font-variant-ligatures:no-common-li=
gatures"><br></span></div><div><span style=3D"font-variant-ligatures:no-com=
mon-ligatures">Let&#39;s see...ooh that was easy!!</span></div><div><span s=
tyle=3D"font-variant-ligatures:no-common-ligatures"><br></span></div><div><=
span style=3D"font-variant-ligatures:no-common-ligatures"><p style=3D"margi=
n:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Men=
lo;color:rgb(0,0,0)"><span style=3D"font-variant-ligatures:no-common-ligatu=
res">raku -ne &#39;.say if &quot;Start&quot; ff (\$_ eq &quot;Mark&quot; &am=
p;&amp; ++\$ %% 2)&#39; example.txt=C2=A0</span></p><div><span style=3D"font=
-variant-ligatures:no-common-ligatures"><br></span></div></span></div><div>=
<span style=3D"font-variant-ligatures:no-common-ligatures">That increments =
the anonymous=C2=A0state variable \$ and then checks if it is divisible by 2=
, so that only every 2nd=C2=A0<span style=3D"color:rgb(0,0,0);font-size:med=
ium"><font face=3D"monospace">Mark</font></span>=C2=A0returns True</span></=
div><div><span style=3D"font-variant-ligatures:no-common-ligatures"><br></s=
pan></div><div><span style=3D"font-variant-ligatures:no-common-ligatures">D=
on&#39;t know if I&#39;ll ever need it, fun to have it.</span></div><div><s=
pan style=3D"font-variant-ligatures:no-common-ligatures"><br></span></div><=
div><div><div dir=3D"ltr" class=3D"gmail_signature">-y<br></div></div><br><=
/div></div></div></div></div></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr" class=3D"gmail_attr">On Tue, Jul 28, 2020 at 7:09 PM Brad Gilbert =
&lt;<a href=3D"mailto:b2gills@gmail.com">b2gills@gmail.com</a>&gt; wrote:<b=
r></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,20=
4,204);padding-left:1ex"><div dir=3D"ltr">A regex doesn&#39;t have to match=
the entire string.<div><br></div><div>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ / bc=
/</div><div>=C2=A0 =C2=A0 # =EF=BD=A2bc=EF=BD=A3</div><div><br></div><div>=
A string has to match exactly with the smart-match. (`ff` and `fff` do smar=
t-match)</div><div><br></div><div>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;bc&#=
39; # False</div><div>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;abcd&#39; # True=
</div><div><br></div><div>A string inside of a regex only makes that a sing=
le atom, it does not make it match like just a string.</div><div><br>=C2=A0=
=C2=A0 &#39;abcd&#39; ~~ / &#39;bc&#39; /<br>=C2=A0 =C2=A0 # =EF=BD=A2bc=
=EF=BD=A3<br></div><div><br></div><div>=C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39;=
~~ / aB+ /</div><div>=C2=A0 =C2=A0 =EF=BD=A2aB=EF=BD=A3<br></div><div><br>=
</div><div>=C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / &quot;aB&quot;+ /</div=
><div>=C2=A0 =C2=A0 =EF=BD=A2aBaBaB=EF=BD=A3</div><div><br></div><div>In fa=
ct a string inside of a regex doesn&#39;t do much more than square brackets=
..</div><div><br>=C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / [aB]+ /<br>=C2=A0=
=C2=A0 =EF=BD=A2aBaBaB=EF=BD=A3<br></div><div><br></div><div>If you want t=
he regex to match fully, add a beginning of string and end of string marker=
..</div><div><br>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ bc \$ /<br>=C2=A0 =C2=A0=
# Nil<br></div><br>=C2=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ abcd \$ /<div>=C2=A0=
=C2=A0 # =EF=BD=A2abcd=EF=BD=A3</div><div><br></div><div>---</div><div><br=
></div><div>Since `ff` can begin and end at the same time, the following is=
turning on and off at almost every iteration of the loop after it starts.<=
/div><div><br></div><div><div>=C2=A0 =C2=A0 \$ raku -ne &#39;.put if /star {=
print q[on ]}/ ff /start {print q[off ]}/ ;&#39; startling.txt <br>=C2=A0 =
=C2=A0 on star<br>=C2=A0 =C2=A0 on off start<br>=C2=A0 =C2=A0 on off startl=
<br>=C2=A0 =C2=A0 on off startli<br>=C2=A0 =C2=A0 on off startlin<br>=C2=A0=
=C2=A0 on off startling<br></div></div></div><br><div class=3D"gmail_quote=
"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Jul 28, 2020 at 1:43 PM Wil=
liam Michels &lt;<a href=3D"mailto:wjm1@caa.columbia.edu" target=3D"_blank"=
>wjm1@caa.columbia.edu</a>&gt; wrote:<br></div><blockquote class=3D"gmail_q=
uote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-s=
Brad and Larry, for explaining the &quot;ff&quot; and &quot;fff&quot; infix=
<br>
operators in Raku to me!<br>
<br>
I have to admit that I&#39;m still fuzzy on the particulars between &quot;f=
f&quot;<br>
and &quot;fff&quot;, since I am not familiar with the sed function. I can<b=
r>
certainly understand how useful these functions could be to &#39;pull out<b=
r>
all PGP signatures&#39; from a file (which was the Perl5 example given in<b=
r>
the Oracle Linux Blog). So I can now=C2=A0 pull out the html &quot;head&quo=
t; section<br>
from the page _ <a href=3D"https://raku.org/fun/" rel=3D"noreferrer" target=
=3D"_blank">https://raku.org/fun/</a> _ (saved locally as file<br>
&quot;fun.txt&quot;) using the following Raku code:<br>
<br>
; fun.txt<br>
=C2=A0 =C2=A0 &lt;meta charset=3D&quot;utf-8&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;meta http-equiv=3D&quot;X-UA-Compatible&quot; content=3D&=
quot;IE=3Dedge&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;meta name=3D&quot;viewport&quot; content=3D&quot;width=3D=
device-width, initial-scale=3D1&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;title&gt;Raku is optimized for fun!&lt;/title&gt;<br>
<br>
<br>
icon&quot; type=3D&quot;image/x-icon&quot;&gt;<br>
rel=3D&quot;stylesheet&quot;&gt;<br>
quot; rel=3D&quot;stylesheet&quot;&gt;<br>
esheet&quot;&gt;<br>
<br>
user@mbook:~\$<br>
<br>
What I&#39;m less clear on is how the code below is functioning. I first<br=
>
print out file named &quot;startling.txt&quot; with &#39;cat&#39;:=C2=A0 it=
&#39;s supposed to<br>
r 2&quot;, etc.<br>
After the &#39;cat&#39; example, I show three examples with Perl(v5.26.3) a=
nd<br>
three examples with Raku(2020.06), generally comparing literal vs<br>
regex arguments.<br>
<br>
The first two Perl5 examples returns nothing; the third Perl5 example<br>
returns everything after the &quot;star&quot; line. For the Raku code, the<=
br>
&#39;DWIMmiest&#39; output below is the first Raku example, which returns t=
wo<br>
lines, &quot;star&quot; and &quot;start&quot;. This is what I expected/desi=
red. But I&#39;m<br>
not really understanding what&#39;s happening with the other 2 Raku<br>
examples (which return everything after the &quot;star&quot; line):<br>
<br>
user@mbook:~\$ cat startling.txt<br>
s<br>
st<br>
sta<br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
<br>
user@mbook:~\$ perl -nE &#39;print if &quot;star&quot; .. &quot;start&quot; =
;&#39; startling.txt<br>
user@mbook:~\$ perl -nE &#39;print if /&quot;star&quot;/ .. /&quot;start&quo=
t;/ ;&#39; startling.txt<br>
user@mbook:~\$ perl -nE &#39;print if /star/ .. /start/ ;&#39; startling.txt=
<br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
user@mbook:~\$ raku -ne &#39;.put if &quot;star&quot; ff &quot;start&quot; ;=
&#39; startling.txt<br>
star<br>
start<br>
user@mbook:~\$ raku -ne &#39;.put if /&quot;star&quot;/ ff /&quot;start&quot=
;/ ;&#39; startling.txt<br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
user@mbook:~\$ raku -ne &#39;.put if /star/ ff /start/ ;&#39; startling.txt<=
br>
star<br>
start<br>
startl<br>
startli<br>
startlin<br>
startling<br>
user@mbook:~\$<br>
<br>
I&#39;m all in favor of improving the &quot;ff&quot; and &quot;fff&quot; fu=
nctions in Raku<br>
over their Perl5 counterparts, but I&#39;m hoping to gain a better<br>
(mnemonic?) way of remembering the expected return values with literal<br>
vs regex arguments.<br>
<br>
Any assistance appreciated, Bill.<br>
<br>
<br>
<br>
<br>
<br>
<br>
On Sun, Jul 26, 2020 at 10:04 AM Larry Wall &lt;<a href=3D"mailto:larry@wal=
l.org" target=3D"_blank">larry@wall.org</a>&gt; wrote:<br>
&gt;<br>
&gt; On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:<br>
&gt; : In the above two cases ff and fff would behave identically.<br>
&gt; :<br>
&gt; : The difference shines when the beginning marker can look like the en=
d<br>
&gt; : marker.<br>
&gt;<br>
&gt; The way I think of it is this:=C2=A0 You come to the end of &quot;ff&q=
uot; sooner, so you<br>
&gt; do the end test immediately after passing the start test.=C2=A0 You co=
me to the<br>
&gt; end of &quot;fff&quot; later, so the end test is delayed to the next i=
teration from<br>
&gt; the start test.=C2=A0 (Same mnemonic for .. and ... in Perl, by the wa=
y, since<br>
&gt; ff and fff were modeled on .. and ... (in their scalar form), but we s=
tole<br>
&gt; .. and ... in Raku for ranges and sequences so we needed something els=
e.)<br>
&gt;<br>
&gt; I suppose if you&#39;re musical you can come up with mnemonics based o=
n &quot;fff&quot;<br>
&gt; being louder than &quot;ff&quot;, so it echoes longer before it stops.=
...=C2=A0 :)<br>
&gt;<br>
&gt; Larry<br>
</blockquote></div>
</blockquote></div>

--00000000000056534505abd8ec59--
```
 0
not
8/1/2020 11:03:58 PM
```--000000000000b5d2bb05abdb7643
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Yary, Nice code!

The general approach of using an anonymous counter is useful to me. Below
are  examples when I only want to recover the first one or two blocks of
text starting with "Start" and ending with "Mark" (nota bene: I took your
example text and deleted the blank lines):

user@book:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 1) fff (\$_ eq
"Mark" && \$++ < 1);' yary_ff_example2.txt
Start
hi print me
yes!
Mark
user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 1) ff (\$_ eq
"Mark" && \$++ < 1);' yary_ff_example2.txt
Start
hi print me
yes!
Mark
user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 2) fff (\$_ eq
"Mark" && \$++ < 2);' yary_ff_example2.txt
Start
hi print me
yes!
Mark
Start
We're back!
Mark
user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 2) ff (\$_ eq
"Mark" && \$++ < 2);' yary_ff_example2.txt
Start
hi print me
yes!
Mark
Start
We're back!
Mark
Still here!
Start
haha that Start does nothing
going to end it now
Mark
!bye bye don't see me!
user@mbook:~\$

I guess I have to say--I'm still a little surprised by the last result
using the "ff" infix operator. I'd appreciate knowing why "ff" and "fff"
behave differently in the last two examples, since the beginning marker
doesn't look anything like the end marker (suggesting they should act
identically). Also, is there a simpler way to write the conditional?

Thx, Bill.

On Sat, Aug 1, 2020 at 4:04 PM yary <not.com@gmail.com> wrote:
>
> This made me want to try a contrived puzzle, use 'fff' to show things
between a "start" and 2nd "mark" line. That is, print any line below not
marked with "!" at the start
>
> \$ cat example.txt
>
> !ignore me
>
> Start
>
> hi print me
>
> yes!
>
> Mark
>
> still print me
>
> Mark
>
> !ignore this line
>
> !this line too
>
> Start
>
> We're back!
>
> Mark
>
> Still here!
>
> Start
>
> haha that Start does nothing
>
> going to end it now
>
> Mark
>
> !bye bye don't see me!
>
>
> Let's see...ooh that was easy!!
>
> raku -ne '.say if "Start" ff (\$_ eq "Mark" && ++\$ %% 2)' example.txt
>
>
> That increments the anonymous state variable \$ and then checks if it is
divisible by 2, so that only every 2nd Mark returns True
>
> Don't know if I'll ever need it, fun to have it.
>
> -y
>
>
> On Tue, Jul 28, 2020 at 7:09 PM Brad Gilbert <b2gills@gmail.com> wrote:
>>
>> A regex doesn't have to match the entire string.
>>
>>     'abcd' ~~ / bc /
>>     # =EF=BD=A2bc=EF=BD=A3
>>
>> A string has to match exactly with the smart-match. (`ff` and `fff` do
smart-match)
>>
>>     'abcd' ~~ 'bc' # False
>>     'abcd' ~~ 'abcd' # True
>>
>> A string inside of a regex only makes that a single atom, it does not
make it match like just a string.
>>
>>     'abcd' ~~ / 'bc' /
>>     # =EF=BD=A2bc=EF=BD=A3
>>
>>      'aBaBaB' ~~ / aB+ /
>>     =EF=BD=A2aB=EF=BD=A3
>>
>>      'aBaBaB' ~~ / "aB"+ /
>>     =EF=BD=A2aBaBaB=EF=BD=A3
>>
>> In fact a string inside of a regex doesn't do much more than square
brackets.
>>
>>      'aBaBaB' ~~ / [aB]+ /
>>     =EF=BD=A2aBaBaB=EF=BD=A3
>>
>> If you want the regex to match fully, add a beginning of string and end
of string marker.
>>
>>     'abcd' ~~ / ^ bc \$ /
>>     # Nil
>>
>>     'abcd' ~~ / ^ abcd \$ /
>>     # =EF=BD=A2abcd=EF=BD=A3
>>
>> ---
>>
>> Since `ff` can begin and end at the same time, the following is turning
on and off at almost every iteration of the loop after it starts.
>>
>>     \$ raku -ne '.put if /star {print q[on ]}/ ff /start {print q[off ]}/
;' startling.txt
>>     on star
>>     on off start
>>     on off startl
>>     on off startli
>>     on off startlin
>>     on off startling
>>
>> On Tue, Jul 28, 2020 at 1:43 PM William Michels <wjm1@caa.columbia.edu>
wrote:
>>>
>>> Thank you, Brad and Larry, for explaining the "ff" and "fff" infix
>>> operators in Raku to me!
>>>
>>> I have to admit that I'm still fuzzy on the particulars between "ff"
>>> and "fff", since I am not familiar with the sed function. I can
>>> certainly understand how useful these functions could be to 'pull out
>>> all PGP signatures' from a file (which was the Perl5 example given in
>>> the Oracle Linux Blog). So I can now  pull out the html "head" section
>>> from the page _ https://raku.org/fun/ _ (saved locally as file
>>> "fun.txt") using the following Raku code:
>>>
>>>     <meta charset=3D"utf-8">
>>>     <meta http-equiv=3D"X-UA-Compatible" content=3D"IE=3Dedge">
>>>     <meta name=3D"viewport" content=3D"width=3Ddevice-width, initial-sc=
ale=3D1">
>>>     <title>Raku is optimized for fun!</title>
>>>
>>>
>>>     <link href=3D"/favicon.ico" rel=3D"shortcut icon" type=3D"image/x-i=
con">
rel=3D"stylesheet">
>>>
>>> user@mbook:~\$
>>>
>>> What I'm less clear on is how the code below is functioning. I first
>>> print out file named "startling.txt" with 'cat':  it's supposed to
>>> stand in for a text delimited linewise by "header 1", "header 2", etc.
>>> After the 'cat' example, I show three examples with Perl(v5.26.3) and
>>> three examples with Raku(2020.06), generally comparing literal vs
>>> regex arguments.
>>>
>>> The first two Perl5 examples returns nothing; the third Perl5 example
>>> returns everything after the "star" line. For the Raku code, the
>>> 'DWIMmiest' output below is the first Raku example, which returns two
>>> lines, "star" and "start". This is what I expected/desired. But I'm
>>> not really understanding what's happening with the other 2 Raku
>>> examples (which return everything after the "star" line):
>>>
>>> user@mbook:~\$ cat startling.txt
>>> s
>>> st
>>> sta
>>> star
>>> start
>>> startl
>>> startli
>>> startlin
>>> startling
>>>
>>> user@mbook:~\$ perl -nE 'print if "star" .. "start" ;' startling.txt
>>> user@mbook:~\$ perl -nE 'print if /"star"/ .. /"start"/ ;' startling.txt
>>> user@mbook:~\$ perl -nE 'print if /star/ .. /start/ ;' startling.txt
>>> star
>>> start
>>> startl
>>> startli
>>> startlin
>>> startling
>>> user@mbook:~\$ raku -ne '.put if "star" ff "start" ;' startling.txt
>>> star
>>> start
>>> user@mbook:~\$ raku -ne '.put if /"star"/ ff /"start"/ ;' startling.txt
>>> star
>>> start
>>> startl
>>> startli
>>> startlin
>>> startling
>>> user@mbook:~\$ raku -ne '.put if /star/ ff /start/ ;' startling.txt
>>> star
>>> start
>>> startl
>>> startli
>>> startlin
>>> startling
>>> user@mbook:~\$
>>>
>>> I'm all in favor of improving the "ff" and "fff" functions in Raku
>>> over their Perl5 counterparts, but I'm hoping to gain a better
>>> (mnemonic?) way of remembering the expected return values with literal
>>> vs regex arguments.
>>>
>>> Any assistance appreciated, Bill.
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sun, Jul 26, 2020 at 10:04 AM Larry Wall <larry@wall.org> wrote:
>>> >
>>> > On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
>>> > : In the above two cases ff and fff would behave identically.
>>> > :
>>> > : The difference shines when the beginning marker can look like the
end
>>> > : marker.
>>> >
>>> > The way I think of it is this:  You come to the end of "ff" sooner,
so you
>>> > do the end test immediately after passing the start test.  You come
to the
>>> > end of "fff" later, so the end test is delayed to the next iteration
from
>>> > the start test.  (Same mnemonic for .. and ... in Perl, by the way,
since
>>> > ff and fff were modeled on .. and ... (in their scalar form), but we
stole
>>> > .. and ... in Raku for ranges and sequences so we needed something
else.)
>>> >
>>> > I suppose if you're musical you can come up with mnemonics based on
"fff"
>>> > being louder than "ff", so it echoes longer before it stops...  :)
>>> >
>>> > Larry

--000000000000b5d2bb05abdb7643
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi Yary, Nice code! <br></div><div><br></div><div>The=
general approach of using an anonymous counter is useful to me. Below are =
=C2=A0examples when I only want to recover the first one or two blocks of t=
ext starting with &quot;Start&quot; and ending with &quot;Mark&quot; (nota =
bene: I took your example text and deleted the blank lines):</div><br>user@=
book:~\$ raku -ne &#39; say \$_ if (\$_ eq &quot;Start&quot; &amp;&amp; \$++ &l=
t; 1) fff (\$_ eq &quot;Mark&quot; &amp;&amp; \$++ &lt; 1);&#39; yary_ff_exam=
ple2.txt<br>Start<br>hi print me<br>yes!<br>Mark<br>user@mbook:~\$ raku -ne =
&#39; say \$_ if (\$_ eq &quot;Start&quot; &amp;&amp; \$++ &lt; 1) ff (\$_ eq &=
quot;Mark&quot; &amp;&amp; \$++ &lt; 1);&#39; yary_ff_example2.txt<br>Start<=
br>hi print me<br>yes!<br>Mark<br>user@mbook:~\$ raku -ne &#39; say \$_ if (\$=
_ eq &quot;Start&quot; &amp;&amp; \$++ &lt; 2) fff (\$_ eq &quot;Mark&quot; &=
amp;&amp; \$++ &lt; 2);&#39; yary_ff_example2.txt<br>Start<br>hi print me<br=
>yes!<br>Mark<br>Start<br>We&#39;re back!<br>Mark<br>user@mbook:~\$ raku -ne=
&#39; say \$_ if (\$_ eq &quot;Start&quot; &amp;&amp; \$++ &lt; 2) ff (\$_ eq =
&quot;Mark&quot; &amp;&amp; \$++ &lt; 2);&#39; yary_ff_example2.txt<br>Start=
<br>hi print me<br>yes!<br>Mark<br>Start<br>We&#39;re back!<br>Mark<br>Stil=
l here!<br>Start<br>haha that Start does nothing<br>going to end it now<br>=
Mark<br>!bye bye don&#39;t see me!<br><div>user@mbook:~\$</div><div><br></di=
v><div>I guess I have to say--I&#39;m still a little surprised by the last =
result using the &quot;ff&quot; infix operator. I&#39;d appreciate knowing =
why &quot;ff&quot; and &quot;fff&quot; behave differently in the last two e=
xamples, since the beginning marker doesn&#39;t look anything like the end =
marker (suggesting they should act identically). Also, is there a simpler w=
ay to write the conditional?<br></div><div><br></div><div>Thx, Bill. <br></=
div><div><br></div><div><br></div><br>On Sat, Aug 1, 2020 at 4:04 PM yary &=
lt;<a href=3D"mailto:not.com@gmail.com" target=3D"_blank">not.com@gmail.com=
</a>&gt; wrote:<br>&gt;<br>&gt; This made me want to try a contrived puzzle=
, use &#39;fff&#39; to show things between a &quot;start&quot; and 2nd &quo=
t;mark&quot; line. That is, print any line below not marked with &quot;!&qu=
ot; at the start<br>&gt;<br>&gt; \$ cat example.txt<br>&gt;<br>&gt; !ignore =
me<br>&gt;<br>&gt; Start<br>&gt;<br>&gt; hi print me<br>&gt;<br>&gt; yes!<b=
r>&gt;<br>&gt; Mark<br>&gt;<br>&gt; still print me<br>&gt;<br>&gt; Mark<br>=
&gt;<br>&gt; !ignore this line<br>&gt;<br>&gt; !this line too<br>&gt;<br>&g=
t; Start<br>&gt;<br>&gt; We&#39;re back!<br>&gt;<br>&gt; Mark<br>&gt;<br>&g=
t; Still here!<br>&gt;<br>&gt; Start<br>&gt;<br>&gt; haha that Start does n=
othing<br>&gt;<br>&gt; going to end it now<br>&gt;<br>&gt; Mark<br>&gt;<br>=
&gt; !bye bye don&#39;t see me!<br>&gt;<br>&gt;<br>&gt; Let&#39;s see...ooh=
that was easy!!<br>&gt;<br>&gt; raku -ne &#39;.say if &quot;Start&quot; ff=
(\$_ eq &quot;Mark&quot; &amp;&amp; ++\$ %% 2)&#39; example.txt<br>&gt;<br>&=
gt;<br>&gt; That increments the anonymous state variable \$ and then checks =
if it is divisible by 2, so that only every 2nd Mark returns True<br>&gt;<b=
r>&gt; Don&#39;t know if I&#39;ll ever need it, fun to have it.<br>&gt;<br>=
&gt; -y<br>&gt;<br>&gt;<br>&gt; On Tue, Jul 28, 2020 at 7:09 PM Brad Gilber=
t &lt;<a href=3D"mailto:b2gills@gmail.com" target=3D"_blank">b2gills@gmail.=
com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; A regex doesn&#39;t have to matc=
h the entire string.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~=
~ / bc /<br>&gt;&gt; =C2=A0 =C2=A0 # =EF=BD=A2bc=EF=BD=A3<br>&gt;&gt;<br>&g=
t;&gt; A string has to match exactly with the smart-match. (`ff` and `fff` =
do smart-match)<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#3=
9;bc&#39; # False<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;abcd&#39=
; # True<br>&gt;&gt;<br>&gt;&gt; A string inside of a regex only makes that=
a single atom, it does not make it match like just a string.<br>&gt;&gt;<b=
r>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / &#39;bc&#39; /<br>&gt;&gt; =C2=
=A0 =C2=A0 # =EF=BD=A2bc=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 =C2=
=A0&#39;aBaBaB&#39; ~~ / aB+ /<br>&gt;&gt; =C2=A0 =C2=A0 =EF=BD=A2aB=EF=BD=
=A3<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / &quot=
;aB&quot;+ /<br>&gt;&gt; =C2=A0 =C2=A0 =EF=BD=A2aBaBaB=EF=BD=A3<br>&gt;&gt;=
<br>&gt;&gt; In fact a string inside of a regex doesn&#39;t do much more th=
an square brackets.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB=
&#39; ~~ / [aB]+ /<br>&gt;&gt; =C2=A0 =C2=A0 =EF=BD=A2aBaBaB=EF=BD=A3<br>&g=
t;&gt;<br>&gt;&gt; If you want the regex to match fully, add a beginning of=
string and end of string marker.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#3=
9;abcd&#39; ~~ / ^ bc \$ /<br>&gt;&gt; =C2=A0 =C2=A0 # Nil<br>&gt;&gt;<br>&g=
t;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ abcd \$ /<br>&gt;&gt; =C2=A0 =C2=
=A0 # =EF=BD=A2abcd=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; ---<br>&gt;&gt;<br>&gt=
;&gt; Since `ff` can begin and end at the same time, the following is turni=
ng on and off at almost every iteration of the loop after it starts.<br>&gt=
;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 \$ raku -ne &#39;.put if /star {print q[on ]=
}/ ff /start {print q[off ]}/ ;&#39; startling.txt<br>&gt;&gt; =C2=A0 =C2=
=A0 on star<br>&gt;&gt; =C2=A0 =C2=A0 on off start<br>&gt;&gt; =C2=A0 =C2=
=A0 on off startl<br>&gt;&gt; =C2=A0 =C2=A0 on off startli<br>&gt;&gt; =C2=
=A0 =C2=A0 on off startlin<br>&gt;&gt; =C2=A0 =C2=A0 on off startling<br>&g=
t;&gt;<br>&gt;&gt; On Tue, Jul 28, 2020 at 1:43 PM William Michels &lt;<a h=
ref=3D"mailto:wjm1@caa.columbia.edu" target=3D"_blank">wjm1@caa.columbia.ed=
u</a>&gt; wrote:<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Thank you, Brad and Larry,=
for explaining the &quot;ff&quot; and &quot;fff&quot; infix<br>&gt;&gt;&gt=
; operators in Raku to me!<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; I have to admit =
that I&#39;m still fuzzy on the particulars between &quot;ff&quot;<br>&gt;&=
gt;&gt; and &quot;fff&quot;, since I am not familiar with the sed function.=
I can<br>&gt;&gt;&gt; certainly understand how useful these functions coul=
d be to &#39;pull out<br>&gt;&gt;&gt; all PGP signatures&#39; from a file (=
which was the Perl5 example given in<br>&gt;&gt;&gt; the Oracle Linux Blog)=
.. So I can now =C2=A0pull out the html &quot;head&quot; section<br>&gt;&gt;=
&gt; from the page _ <a href=3D"https://raku.org/fun/" target=3D"_blank">ht=
tps://raku.org/fun/</a> _ (saved locally as file<br>&gt;&gt;&gt; &quot;fun.=
txt&quot;) using the following Raku code:<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; u=
a charset=3D&quot;utf-8&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;meta ht=
tp-equiv=3D&quot;X-UA-Compatible&quot; content=3D&quot;IE=3Dedge&quot;&gt;<=
br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;meta name=3D&quot;viewport&quot; content=
=3D&quot;width=3Ddevice-width, initial-scale=3D1&quot;&gt;<br>&gt;&gt;&gt; =
=C2=A0 =C2=A0 &lt;title&gt;Raku is optimized for fun!&lt;/title&gt;<br>&gt;=
t;/favicon.ico&quot; rel=3D&quot;shortcut icon&quot; type=3D&quot;image/x-i=
p/css/bootstrap.min.css&quot; rel=3D&quot;stylesheet&quot;&gt;<br>&gt;&gt;&=
css&quot; rel=3D&quot;stylesheet&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &l=
\$<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; What I&#39;m less clear on is how the cod=
e below is functioning. I first<br>&gt;&gt;&gt; print out file named &quot;=
startling.txt&quot; with &#39;cat&#39;: =C2=A0it&#39;s supposed to<br>&gt;&=
gt;&gt; stand in for a text delimited linewise by &quot;header 1&quot;, &qu=
ot;header 2&quot;, etc.<br>&gt;&gt;&gt; After the &#39;cat&#39; example, I =
show three examples with Perl(v5.26.3) and<br>&gt;&gt;&gt; three examples w=
ith Raku(2020.06), generally comparing literal vs<br>&gt;&gt;&gt; regex arg=
uments.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; The first two Perl5 examples return=
s nothing; the third Perl5 example<br>&gt;&gt;&gt; returns everything after=
the &quot;star&quot; line. For the Raku code, the<br>&gt;&gt;&gt; &#39;DWI=
Mmiest&#39; output below is the first Raku example, which returns two<br>&g=
t;&gt;&gt; lines, &quot;star&quot; and &quot;start&quot;. This is what I ex=
pected/desired. But I&#39;m<br>&gt;&gt;&gt; not really understanding what&#=
39;s happening with the other 2 Raku<br>&gt;&gt;&gt; examples (which return=
everything after the &quot;star&quot; line):<br>&gt;&gt;&gt;<br>&gt;&gt;&g=
t; user@mbook:~\$ cat startling.txt<br>&gt;&gt;&gt; s<br>&gt;&gt;&gt; st<br>=
&gt;&gt;&gt; sta<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt;=
startl<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; st=
artling<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; user@mbook:~\$ perl -nE &#39;print i=
f &quot;star&quot; .. &quot;start&quot; ;&#39; startling.txt<br>&gt;&gt;&gt=
; user@mbook:~\$ perl -nE &#39;print if /&quot;star&quot;/ .. /&quot;start&q=
uot;/ ;&#39; startling.txt<br>&gt;&gt;&gt; user@mbook:~\$ perl -nE &#39;prin=
t if /star/ .. /start/ ;&#39; startling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt=
;&gt; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt; =
startlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;&gt; user@mbook:~\$ raku -ne &=
#39;.put if &quot;star&quot; ff &quot;start&quot; ;&#39; startling.txt<br>&=
gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt; user@mbook:~\$ raku -=
ne &#39;.put if /&quot;star&quot;/ ff /&quot;start&quot;/ ;&#39; startling.=
txt<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt; startl<br>&g=
t;&gt;&gt; startli<br>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; startling<br>&g=
t;&gt;&gt; user@mbook:~\$ raku -ne &#39;.put if /star/ ff /start/ ;&#39; sta=
rtling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt; start=
l<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; startlin=
g<br>&gt;&gt;&gt; user@mbook:~\$<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; I&#39;m all=
in favor of improving the &quot;ff&quot; and &quot;fff&quot; functions in =
Raku<br>&gt;&gt;&gt; over their Perl5 counterparts, but I&#39;m hoping to g=
ain a better<br>&gt;&gt;&gt; (mnemonic?) way of remembering the expected re=
turn values with literal<br>&gt;&gt;&gt; vs regex arguments.<br>&gt;&gt;&gt=
;<br>&gt;&gt;&gt; Any assistance appreciated, Bill.<br>&gt;&gt;&gt;<br>&gt;=
&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br=
>&gt;&gt;&gt; On Sun, Jul 26, 2020 at 10:04 AM Larry Wall &lt;<a href=3D"ma=
ilto:larry@wall.org" target=3D"_blank">larry@wall.org</a>&gt; wrote:<br>&gt=
;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; On Sat, Jul 25, 2020 at 04:32:02PM -050=
0, Brad Gilbert wrote:<br>&gt;&gt;&gt; &gt; : In the above two cases ff and=
fff would behave identically.<br>&gt;&gt;&gt; &gt; :<br>&gt;&gt;&gt; &gt; =
: The difference shines when the beginning marker can look like the end<br>=
&gt;&gt;&gt; &gt; : marker.<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; The w=
ay I think of it is this: =C2=A0You come to the end of &quot;ff&quot; soone=
r, so you<br>&gt;&gt;&gt; &gt; do the end test immediately after passing th=
e start test.=C2=A0 You come to the<br>&gt;&gt;&gt; &gt; end of &quot;fff&q=
uot; later, so the end test is delayed to the next iteration from<br>&gt;&g=
t;&gt; &gt; the start test. =C2=A0(Same mnemonic for .. and ... in Perl, by=
the way, since<br>&gt;&gt;&gt; &gt; ff and fff were modeled on .. and ... =
(in their scalar form), but we stole<br>&gt;&gt;&gt; &gt; .. and ... in Rak=
u for ranges and sequences so we needed something else.)<br>&gt;&gt;&gt; &g=
t;<br>&gt;&gt;&gt; &gt; I suppose if you&#39;re musical you can come up wit=
h mnemonics based on &quot;fff&quot;<br>&gt;&gt;&gt; &gt; being louder than=
&quot;ff&quot;, so it echoes longer before it stops... =C2=A0:)<br>&gt;&gt=
;&gt; &gt;<br>&gt;&gt;&gt; &gt; Larry</div>

--000000000000b5d2bb05abdb7643--
```
 0
perl6
8/2/2020 2:05:25 AM
```--00000000000092048205abe9055d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

tl;dr: is this a Rakudo issue?

ooh a puzzle =F0=9F=98=80 why do 'ff' and 'fff' give different results in t=
his case?
The start & end are disjoint, the \$++ should only run when the string test
is true, so I expect 'ff' and 'fff' to behave the same also.

Golfing a little

\$ raku -e 'my @input=3Dqw<nope + B C D - 1 - no + E F - 2 3 - never never +=
G
- 4 5 - hide>; \
say "With ff:  ",@input.grep({(\$_ eq "+" && \$++ < 2) ff  (\$_ eq "-" && \$++
< 2)}); \
say "With fff: ",@input.grep({(\$_ eq "+" && \$++ < 2) fff (\$_ eq "-" && \$++
< 2)});'

With ff:  (+ B C D - + E F - 2 3 - never never + G - 4 5 - hide)
With fff: (+ B C D - + E F -)

With both of these, the flip-flop turns on with the first '+' and turns off
with the first '-'
With both of these, the 2nd '+' turns on the flip-flop.
WIth 'ff', the flip-flop never turns off, with 'fff' the flip-flop turns
off when it encounters the next '-'

I wonder... let's have the end of the flip-flop say every time it runs

raku -e 'my @input=3Dqw<nope + B C D - ?? - no + E F - !! ## - never never =
+
G - %% && - hide>; \
say "With ff: ";say @input.grep({(\$_ eq "+" && \$++ < 2) ff  ("checking
\$_".say && \$_ eq "-" && say "increment to " ~ ++\$ )}); \
say "With fff:";say @input.grep({(\$_ eq "+" && \$++ < 2) fff ("checking
\$_".say && \$_ eq "-" && say "increment to " ~ ++\$ )});'

With ff:
checking nope
checking +
checking B
checking C
checking D
checking -
increment to 1
checking ??
checking -
increment to 2
checking no
checking +
checking E
checking F
checking -
increment to 3
checking !!
checking ##
checking -
increment to 4
checking never
checking never
checking +
checking G
checking -
increment to 5
checking %%
checking &&
checking -
increment to 6
checking hide
(+ B C D - + E F -)
With fff:
checking B
checking C
checking D
checking -
increment to 1
checking E
checking F
checking -
increment to 2
(+ B C D - + E F -)

Hey gurus, why is the end check in 'ff' running so much more often than the
end check of 'fff' ?

ps. I had many weird errors, due to having "rake" installed, and having
something autocorrect my "raku" command-line to "rake"!!!

-y

On Sat, Aug 1, 2020 at 10:06 PM William Michels <wjm1@caa.columbia.edu>
wrote:

> Hi Yary, Nice code!
>
> The general approach of using an anonymous counter is useful to me. Below
> are  examples when I only want to recover the first one or two blocks of
> text starting with "Start" and ending with "Mark" (nota bene: I took your
> example text and deleted the blank lines):
>
> user@book:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 1) fff (\$_ eq
> "Mark" && \$++ < 1);' yary_ff_example2.txt
> Start
> hi print me
> yes!
> Mark
> user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 1) ff (\$_ eq
> "Mark" && \$++ < 1);' yary_ff_example2.txt
> Start
> hi print me
> yes!
> Mark
> user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 2) fff (\$_ eq
> "Mark" && \$++ < 2);' yary_ff_example2.txt
> Start
> hi print me
> yes!
> Mark
> Start
> We're back!
> Mark
> user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 2) ff (\$_ eq
> "Mark" && \$++ < 2);' yary_ff_example2.txt
> Start
> hi print me
> yes!
> Mark
> Start
> We're back!
> Mark
> Still here!
> Start
> haha that Start does nothing
> going to end it now
> Mark
> !bye bye don't see me!
> user@mbook:~\$
>
> I guess I have to say--I'm still a little surprised by the last result
> using the "ff" infix operator. I'd appreciate knowing why "ff" and "fff"
> behave differently in the last two examples, since the beginning marker
> doesn't look anything like the end marker (suggesting they should act
> identically). Also, is there a simpler way to write the conditional?
>
> Thx, Bill.
>
>
>
> On Sat, Aug 1, 2020 at 4:04 PM yary <not.com@gmail.com> wrote:
> >
> > This made me want to try a contrived puzzle, use 'fff' to show things
> between a "start" and 2nd "mark" line. That is, print any line below not
> marked with "!" at the start
> >
> > \$ cat example.txt
> >
> > !ignore me
> >
> > Start
> >
> > hi print me
> >
> > yes!
> >
> > Mark
> >
> > still print me
> >
> > Mark
> >
> > !ignore this line
> >
> > !this line too
> >
> > Start
> >
> > We're back!
> >
> > Mark
> >
> > Still here!
> >
> > Start
> >
> > haha that Start does nothing
> >
> > going to end it now
> >
> > Mark
> >
> > !bye bye don't see me!
> >
> >
> > Let's see...ooh that was easy!!
> >
> > raku -ne '.say if "Start" ff (\$_ eq "Mark" && ++\$ %% 2)' example.txt
> >
> >
> > That increments the anonymous state variable \$ and then checks if it is
> divisible by 2, so that only every 2nd Mark returns True
> >
> > Don't know if I'll ever need it, fun to have it.
> >
> > -y
> >
> >
> > On Tue, Jul 28, 2020 at 7:09 PM Brad Gilbert <b2gills@gmail.com> wrote:
> >>
> >> A regex doesn't have to match the entire string.
> >>
> >>     'abcd' ~~ / bc /
> >>     # =EF=BD=A2bc=EF=BD=A3
> >>
> >> A string has to match exactly with the smart-match. (`ff` and `fff` do
> smart-match)
> >>
> >>     'abcd' ~~ 'bc' # False
> >>     'abcd' ~~ 'abcd' # True
> >>
> >> A string inside of a regex only makes that a single atom, it does not
> make it match like just a string.
> >>
> >>     'abcd' ~~ / 'bc' /
> >>     # =EF=BD=A2bc=EF=BD=A3
> >>
> >>      'aBaBaB' ~~ / aB+ /
> >>     =EF=BD=A2aB=EF=BD=A3
> >>
> >>      'aBaBaB' ~~ / "aB"+ /
> >>     =EF=BD=A2aBaBaB=EF=BD=A3
> >>
> >> In fact a string inside of a regex doesn't do much more than square
> brackets.
> >>
> >>      'aBaBaB' ~~ / [aB]+ /
> >>     =EF=BD=A2aBaBaB=EF=BD=A3
> >>
> >> If you want the regex to match fully, add a beginning of string and en=
d
> of string marker.
> >>
> >>     'abcd' ~~ / ^ bc \$ /
> >>     # Nil
> >>
> >>     'abcd' ~~ / ^ abcd \$ /
> >>     # =EF=BD=A2abcd=EF=BD=A3
> >>
> >> ---
> >>
> >> Since `ff` can begin and end at the same time, the following is turnin=
g
> on and off at almost every iteration of the loop after it starts.
> >>
> >>     \$ raku -ne '.put if /star {print q[on ]}/ ff /start {print q[off
> ]}/ ;' startling.txt
> >>     on star
> >>     on off start
> >>     on off startl
> >>     on off startli
> >>     on off startlin
> >>     on off startling
> >>
> >> On Tue, Jul 28, 2020 at 1:43 PM William Michels <wjm1@caa.columbia.edu=
>
> wrote:
> >>>
> >>> Thank you, Brad and Larry, for explaining the "ff" and "fff" infix
> >>> operators in Raku to me!
> >>>
> >>> I have to admit that I'm still fuzzy on the particulars between "ff"
> >>> and "fff", since I am not familiar with the sed function. I can
> >>> certainly understand how useful these functions could be to 'pull out
> >>> all PGP signatures' from a file (which was the Perl5 example given in
> >>> the Oracle Linux Blog). So I can now  pull out the html "head" sectio=
n
> >>> from the page _ https://raku.org/fun/ _ (saved locally as file
> >>> "fun.txt") using the following Raku code:
> >>>
> >>>     <meta charset=3D"utf-8">
> >>>     <meta http-equiv=3D"X-UA-Compatible" content=3D"IE=3Dedge">
> >>>     <meta name=3D"viewport" content=3D"width=3Ddevice-width,
> initial-scale=3D1">
> >>>     <title>Raku is optimized for fun!</title>
> >>>
> >>>
> >>>     <link href=3D"/favicon.ico" rel=3D"shortcut icon" type=3D"image/x=
-icon">
">
> rel=3D"stylesheet">
> >>>
> >>> user@mbook:~\$
> >>>
> >>> What I'm less clear on is how the code below is functioning. I first
> >>> print out file named "startling.txt" with 'cat':  it's supposed to
> >>> stand in for a text delimited linewise by "header 1", "header 2", etc=
..
> >>> After the 'cat' example, I show three examples with Perl(v5.26.3) and
> >>> three examples with Raku(2020.06), generally comparing literal vs
> >>> regex arguments.
> >>>
> >>> The first two Perl5 examples returns nothing; the third Perl5 example
> >>> returns everything after the "star" line. For the Raku code, the
> >>> 'DWIMmiest' output below is the first Raku example, which returns two
> >>> lines, "star" and "start". This is what I expected/desired. But I'm
> >>> not really understanding what's happening with the other 2 Raku
> >>> examples (which return everything after the "star" line):
> >>>
> >>> user@mbook:~\$ cat startling.txt
> >>> s
> >>> st
> >>> sta
> >>> star
> >>> start
> >>> startl
> >>> startli
> >>> startlin
> >>> startling
> >>>
> >>> user@mbook:~\$ perl -nE 'print if "star" .. "start" ;' startling.txt
> >>> user@mbook:~\$ perl -nE 'print if /"star"/ .. /"start"/ ;'
> startling.txt
> >>> user@mbook:~\$ perl -nE 'print if /star/ .. /start/ ;' startling.txt
> >>> star
> >>> start
> >>> startl
> >>> startli
> >>> startlin
> >>> startling
> >>> user@mbook:~\$ raku -ne '.put if "star" ff "start" ;' startling.txt
> >>> star
> >>> start
> >>> user@mbook:~\$ raku -ne '.put if /"star"/ ff /"start"/ ;' startling.tx=
t
> >>> star
> >>> start
> >>> startl
> >>> startli
> >>> startlin
> >>> startling
> >>> user@mbook:~\$ raku -ne '.put if /star/ ff /start/ ;' startling.txt
> >>> star
> >>> start
> >>> startl
> >>> startli
> >>> startlin
> >>> startling
> >>> user@mbook:~\$
> >>>
> >>> I'm all in favor of improving the "ff" and "fff" functions in Raku
> >>> over their Perl5 counterparts, but I'm hoping to gain a better
> >>> (mnemonic?) way of remembering the expected return values with litera=
l
> >>> vs regex arguments.
> >>>
> >>> Any assistance appreciated, Bill.
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> On Sun, Jul 26, 2020 at 10:04 AM Larry Wall <larry@wall.org> wrote:
> >>> >
> >>> > On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
> >>> > : In the above two cases ff and fff would behave identically.
> >>> > :
> >>> > : The difference shines when the beginning marker can look like the
> end
> >>> > : marker.
> >>> >
> >>> > The way I think of it is this:  You come to the end of "ff" sooner,
> so you
> >>> > do the end test immediately after passing the start test.  You come
> to the
> >>> > end of "fff" later, so the end test is delayed to the next iteratio=
n
> from
> >>> > the start test.  (Same mnemonic for .. and ... in Perl, by the way,
> since
> >>> > ff and fff were modeled on .. and ... (in their scalar form), but w=
e
> stole
> >>> > .. and ... in Raku for ranges and sequences so we needed something
> else.)
> >>> >
> >>> > I suppose if you're musical you can come up with mnemonics based on
> "fff"
> >>> > being louder than "ff", so it echoes longer before it stops...  :)
> >>> >
> >>> > Larry
>

--00000000000092048205abe9055d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div di=
r=3D"ltr"><div>tl;dr: is this a Rakudo issue?</div><div dir=3D"ltr"><br></d=
iv><div dir=3D"ltr">ooh a puzzle =F0=9F=98=80 why do &#39;ff&#39; and &#39;=
fff&#39; give different results in this case? The start &amp; end are disjo=
int, the=C2=A0\$++ should only run when the string test is true, so I expect=
&#39;ff&#39; and &#39;fff&#39; to behave the same also.<div><br></div><div=
>Golfing a little</div><div><br></div><div><div>\$ raku -e &#39;my @input=3D=
qw&lt;nope + B C D - 1 - no + E F - 2 3 - never never + G - 4 5 - hide&gt;;=
\</div><div>say &quot;With ff: =C2=A0&quot;,@input.grep({(\$_ eq &quot;+&qu=
ot; &amp;&amp; \$++ &lt; 2) ff =C2=A0(\$_ eq &quot;-&quot; &amp;&amp; \$++ &lt=
; 2)}); \</div><div>say &quot;With fff: &quot;,@input.grep({(\$_ eq &quot;+&=
quot; &amp;&amp; \$++ &lt; 2) fff (\$_ eq &quot;-&quot; &amp;&amp; \$++ &lt; 2=
)});&#39;</div></div><div><br></div><div><div><font face=3D"monospace">With=
ff: =C2=A0(+ B C D - + E F - 2 3 - never never + G - 4 5 - hide)</font></d=
iv><div><font face=3D"monospace">With fff: (+ B C D - + E F -)</font></div>=
</div><div><br></div><div>With both of these, the flip-flop turns on with t=
he first &#39;+&#39; and turns off with the first &#39;-&#39;</div><div>Wit=
h both of these, the 2nd &#39;+&#39; turns on the flip-flop.</div><div>WIth=
&#39;ff&#39;, the flip-flop never turns off, with &#39;fff&#39; the flip-f=
lop turns off when it encounters the next &#39;-&#39;</div><div><br></div><=
div>I wonder... let&#39;s have the end of the flip-flop say every time it r=
uns</div><div><br></div><div><div>raku -e &#39;my @input=3Dqw&lt;nope + B C=
D - ?? - no + E F - !! ## - never never + G - %% &amp;&amp; - hide&gt;; \<=
/div><div>say &quot;With ff: &quot;;say @input.grep({(\$_ eq &quot;+&quot; &=
amp;&amp; \$++ &lt; 2) ff =C2=A0(&quot;checking \$_&quot;.say &amp;&amp; \$_ e=
q &quot;-&quot; &amp;&amp; say &quot;increment to &quot; ~ ++\$ )}); \</div>=
<div>say &quot;With fff:&quot;;say @input.grep({(\$_ eq &quot;+&quot; &amp;&=
amp; \$++ &lt; 2) fff (&quot;checking \$_&quot;.say &amp;&amp; \$_ eq &quot;-&=
quot; &amp;&amp; say &quot;increment to &quot; ~ ++\$ )});&#39;</div><div><b=
r></div><div><font face=3D"monospace">With ff:=C2=A0</font></div><div><font=
face=3D"monospace">checking nope</font></div><div><font face=3D"monospace"=
>checking +</font></div><div><font face=3D"monospace">checking B</font></di=
v><div><font face=3D"monospace">checking C</font></div><div><font face=3D"m=
onospace">checking D</font></div><div><font face=3D"monospace">checking -</=
font></div><div><font face=3D"monospace">increment to 1</font></div><div><f=
ont face=3D"monospace">checking ??</font></div><div><font face=3D"monospace=
">checking -</font></div><div><font face=3D"monospace">increment to 2</font=
></div><div><font face=3D"monospace">checking no</font></div><div><font fac=
e=3D"monospace">checking +</font></div><div><font face=3D"monospace">checki=
ng E</font></div><div><font face=3D"monospace">checking F</font></div><div>=
<font face=3D"monospace">checking -</font></div><div><font face=3D"monospac=
e">increment to 3</font></div><div><font face=3D"monospace">checking !!</fo=
nt></div><div><font face=3D"monospace">checking ##</font></div><div><font f=
ace=3D"monospace">checking -</font></div><div><font face=3D"monospace">incr=
ement to 4</font></div><div><font face=3D"monospace">checking never</font><=
/div><div><font face=3D"monospace">checking never</font></div><div><font fa=
ce=3D"monospace">checking +</font></div><div><font face=3D"monospace">check=
ing G</font></div><div><font face=3D"monospace">checking -</font></div><div=
><font face=3D"monospace">increment to 5</font></div><div><font face=3D"mon=
ospace">checking %%</font></div><div><font face=3D"monospace">checking &amp=
;&amp;</font></div><div><font face=3D"monospace">checking -</font></div><di=
v><font face=3D"monospace">increment to 6</font></div><div><font face=3D"mo=
nospace">checking hide</font></div><div><font face=3D"monospace">(+ B C D -=
+ E F -)</font></div><div><font face=3D"monospace">With fff:</font></div><=
div><font face=3D"monospace">checking B</font></div><div><font face=3D"mono=
space">checking C</font></div><div><font face=3D"monospace">checking D</fon=
t></div><div><font face=3D"monospace">checking -</font></div><div><font fac=
e=3D"monospace">increment to 1</font></div><div><font face=3D"monospace">ch=
ecking E</font></div><div><font face=3D"monospace">checking F</font></div><=
div><font face=3D"monospace">checking -</font></div><div><font face=3D"mono=
space">increment to 2</font></div><div><font face=3D"monospace">(+ B C D - =
+ E F -)</font></div></div><div><br></div><div>Hey gurus, why is the end ch=
eck in &#39;ff&#39; running so much more often than the end check of &#39;f=
ff&#39; ?</div><div><br></div><div><div>ps. I had many weird errors, due to=
having &quot;rake&quot; installed, and having something autocorrect my &qu=
ot;raku&quot; command-line to &quot;rake&quot;!!!<br><div><br clear=3D"all"=
><div><div dir=3D"ltr" class=3D"gmail_signature">-y<br></div></div><br></di=
v></div></div></div></div></div></div></div></div><br><div class=3D"gmail_q=
uote"><div dir=3D"ltr" class=3D"gmail_attr">On Sat, Aug 1, 2020 at 10:06 PM=
William Michels &lt;<a href=3D"mailto:wjm1@caa.columbia.edu">wjm1@caa.colu=
mbia.edu</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;bor=
Yary, Nice code! <br></div><div><br></div><div>The general approach of usin=
g an anonymous counter is useful to me. Below are =C2=A0examples when I onl=
y want to recover the first one or two blocks of text starting with &quot;S=
tart&quot; and ending with &quot;Mark&quot; (nota bene: I took your example=
text and deleted the blank lines):</div><br>user@book:~\$ raku -ne &#39; sa=
y \$_ if (\$_ eq &quot;Start&quot; &amp;&amp; \$++ &lt; 1) fff (\$_ eq &quot;Ma=
rk&quot; &amp;&amp; \$++ &lt; 1);&#39; yary_ff_example2.txt<br>Start<br>hi p=
rint me<br>yes!<br>Mark<br>user@mbook:~\$ raku -ne &#39; say \$_ if (\$_ eq &q=
uot;Start&quot; &amp;&amp; \$++ &lt; 1) ff (\$_ eq &quot;Mark&quot; &amp;&amp=
; \$++ &lt; 1);&#39; yary_ff_example2.txt<br>Start<br>hi print me<br>yes!<br=
>Mark<br>user@mbook:~\$ raku -ne &#39; say \$_ if (\$_ eq &quot;Start&quot; &a=
mp;&amp; \$++ &lt; 2) fff (\$_ eq &quot;Mark&quot; &amp;&amp; \$++ &lt; 2);&#3=
9; yary_ff_example2.txt<br>Start<br>hi print me<br>yes!<br>Mark<br>Start<br=
>We&#39;re back!<br>Mark<br>user@mbook:~\$ raku -ne &#39; say \$_ if (\$_ eq &=
quot;Start&quot; &amp;&amp; \$++ &lt; 2) ff (\$_ eq &quot;Mark&quot; &amp;&am=
p; \$++ &lt; 2);&#39; yary_ff_example2.txt<br>Start<br>hi print me<br>yes!<b=
r>Mark<br>Start<br>We&#39;re back!<br>Mark<br>Still here!<br>Start<br>haha =
that Start does nothing<br>going to end it now<br>Mark<br>!bye bye don&#39;=
t see me!<br><div>user@mbook:~\$</div><div><br></div><div>I guess I have to =
say--I&#39;m still a little surprised by the last result using the &quot;ff=
&quot; infix operator. I&#39;d appreciate knowing why &quot;ff&quot; and &q=
uot;fff&quot; behave differently in the last two examples, since the beginn=
ing marker doesn&#39;t look anything like the end marker (suggesting they s=
hould act identically). Also, is there a simpler way to write the condition=
al?<br></div><div><br></div><div>Thx, Bill. <br></div><div><br></div><div><=
br></div><br>On Sat, Aug 1, 2020 at 4:04 PM yary &lt;<a href=3D"mailto:not.=
com@gmail.com" target=3D"_blank">not.com@gmail.com</a>&gt; wrote:<br>&gt;<b=
r>&gt; This made me want to try a contrived puzzle, use &#39;fff&#39; to sh=
ow things between a &quot;start&quot; and 2nd &quot;mark&quot; line. That i=
s, print any line below not marked with &quot;!&quot; at the start<br>&gt;<=
br>&gt; \$ cat example.txt<br>&gt;<br>&gt; !ignore me<br>&gt;<br>&gt; Start<=
br>&gt;<br>&gt; hi print me<br>&gt;<br>&gt; yes!<br>&gt;<br>&gt; Mark<br>&g=
t;<br>&gt; still print me<br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; !ignore this=
line<br>&gt;<br>&gt; !this line too<br>&gt;<br>&gt; Start<br>&gt;<br>&gt; =
We&#39;re back!<br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; Still here!<br>&gt;<br=
>&gt; Start<br>&gt;<br>&gt; haha that Start does nothing<br>&gt;<br>&gt; go=
ing to end it now<br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; !bye bye don&#39;t s=
ee me!<br>&gt;<br>&gt;<br>&gt; Let&#39;s see...ooh that was easy!!<br>&gt;<=
br>&gt; raku -ne &#39;.say if &quot;Start&quot; ff (\$_ eq &quot;Mark&quot; =
&amp;&amp; ++\$ %% 2)&#39; example.txt<br>&gt;<br>&gt;<br>&gt; That incremen=
ts the anonymous state variable \$ and then checks if it is divisible by 2, =
so that only every 2nd Mark returns True<br>&gt;<br>&gt; Don&#39;t know if =
I&#39;ll ever need it, fun to have it.<br>&gt;<br>&gt; -y<br>&gt;<br>&gt;<b=
r>&gt; On Tue, Jul 28, 2020 at 7:09 PM Brad Gilbert &lt;<a href=3D"mailto:b=
2gills@gmail.com" target=3D"_blank">b2gills@gmail.com</a>&gt; wrote:<br>&gt=
;&gt;<br>&gt;&gt; A regex doesn&#39;t have to match the entire string.<br>&=
gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / bc /<br>&gt;&gt; =C2=
=A0 =C2=A0 # =EF=BD=A2bc=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; A string has to m=
atch exactly with the smart-match. (`ff` and `fff` do smart-match)<br>&gt;&=
gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;bc&#39; # False<br>&gt=
;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;abcd&#39; # True<br>&gt;&gt;<br>=
&gt;&gt; A string inside of a regex only makes that a single atom, it does =
not make it match like just a string.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0=
&#39;abcd&#39; ~~ / &#39;bc&#39; /<br>&gt;&gt; =C2=A0 =C2=A0 # =EF=BD=A2bc=
=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ /=
aB+ /<br>&gt;&gt; =C2=A0 =C2=A0 =EF=BD=A2aB=EF=BD=A3<br>&gt;&gt;<br>&gt;&g=
t; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / &quot;aB&quot;+ /<br>&gt;&gt; =
=C2=A0 =C2=A0 =EF=BD=A2aBaBaB=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; In fact a st=
ring inside of a regex doesn&#39;t do much more than square brackets.<br>&g=
t;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / [aB]+ /<br>&gt=
;&gt; =C2=A0 =C2=A0 =EF=BD=A2aBaBaB=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; If you=
want the regex to match fully, add a beginning of string and end of string=
marker.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ bc \$ /=
<br>&gt;&gt; =C2=A0 =C2=A0 # Nil<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39=
;abcd&#39; ~~ / ^ abcd \$ /<br>&gt;&gt; =C2=A0 =C2=A0 # =EF=BD=A2abcd=EF=BD=
=A3<br>&gt;&gt;<br>&gt;&gt; ---<br>&gt;&gt;<br>&gt;&gt; Since `ff` can begi=
n and end at the same time, the following is turning on and off at almost e=
very iteration of the loop after it starts.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =
=C2=A0 \$ raku -ne &#39;.put if /star {print q[on ]}/ ff /start {print q[off=
]}/ ;&#39; startling.txt<br>&gt;&gt; =C2=A0 =C2=A0 on star<br>&gt;&gt; =C2=
=A0 =C2=A0 on off start<br>&gt;&gt; =C2=A0 =C2=A0 on off startl<br>&gt;&gt;=
=C2=A0 =C2=A0 on off startli<br>&gt;&gt; =C2=A0 =C2=A0 on off startlin<br>=
&gt;&gt; =C2=A0 =C2=A0 on off startling<br>&gt;&gt;<br>&gt;&gt; On Tue, Jul=
28, 2020 at 1:43 PM William Michels &lt;<a href=3D"mailto:wjm1@caa.columbi=
a.edu" target=3D"_blank">wjm1@caa.columbia.edu</a>&gt; wrote:<br>&gt;&gt;&g=
t;<br>&gt;&gt;&gt; Thank you, Brad and Larry, for explaining the &quot;ff&q=
uot; and &quot;fff&quot; infix<br>&gt;&gt;&gt; operators in Raku to me!<br>=
&gt;&gt;&gt;<br>&gt;&gt;&gt; I have to admit that I&#39;m still fuzzy on th=
e particulars between &quot;ff&quot;<br>&gt;&gt;&gt; and &quot;fff&quot;, s=
ince I am not familiar with the sed function. I can<br>&gt;&gt;&gt; certain=
ly understand how useful these functions could be to &#39;pull out<br>&gt;&=
gt;&gt; all PGP signatures&#39; from a file (which was the Perl5 example gi=
ven in<br>&gt;&gt;&gt; the Oracle Linux Blog). So I can now =C2=A0pull out =
the html &quot;head&quot; section<br>&gt;&gt;&gt; from the page _ <a href=
=3D"https://raku.org/fun/" target=3D"_blank">https://raku.org/fun/</a> _ (s=
aved locally as file<br>&gt;&gt;&gt; &quot;fun.txt&quot;) using the followi=
ng Raku code:<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; user@mbook:~\$ raku -ne &#39;.=
;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;meta http-equiv=3D&quot;X-UA-Compat=
ible&quot; content=3D&quot;IE=3Dedge&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=
=A0 &lt;meta name=3D&quot;viewport&quot; content=3D&quot;width=3Ddevice-wid=
th, initial-scale=3D1&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;title&gt;=
Raku is optimized for fun!&lt;/title&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br=
>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;link href=3D&quot;/favicon.ico&quot; rel=3D=
&quot;shortcut icon&quot; type=3D&quot;image/x-icon&quot;&gt;<br>&gt;&gt;&g=
t; rel=3D&quot;stylesheet&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;link =
href=3D&quot;/bootstrap/css/bootstrap-theme.min.css&quot; rel=3D&quot;style=
css?v=3D1&quot; rel=3D&quot;stylesheet&quot;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt=
t;&gt; What I&#39;m less clear on is how the code below is functioning. I f=
irst<br>&gt;&gt;&gt; print out file named &quot;startling.txt&quot; with &#=
39;cat&#39;: =C2=A0it&#39;s supposed to<br>&gt;&gt;&gt; stand in for a text=
&gt;&gt;&gt; After the &#39;cat&#39; example, I show three examples with Pe=
rl(v5.26.3) and<br>&gt;&gt;&gt; three examples with Raku(2020.06), generall=
y comparing literal vs<br>&gt;&gt;&gt; regex arguments.<br>&gt;&gt;&gt;<br>=
&gt;&gt;&gt; The first two Perl5 examples returns nothing; the third Perl5 =
example<br>&gt;&gt;&gt; returns everything after the &quot;star&quot; line.=
For the Raku code, the<br>&gt;&gt;&gt; &#39;DWIMmiest&#39; output below is=
the first Raku example, which returns two<br>&gt;&gt;&gt; lines, &quot;sta=
r&quot; and &quot;start&quot;. This is what I expected/desired. But I&#39;m=
<br>&gt;&gt;&gt; not really understanding what&#39;s happening with the oth=
er 2 Raku<br>&gt;&gt;&gt; examples (which return everything after the &quot=
;star&quot; line):<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; user@mbook:~\$ cat startl=
ing.txt<br>&gt;&gt;&gt; s<br>&gt;&gt;&gt; st<br>&gt;&gt;&gt; sta<br>&gt;&gt=
;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; sta=
rtli<br>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;&gt;<br>=
&gt;&gt;&gt; user@mbook:~\$ perl -nE &#39;print if &quot;star&quot; .. &quot=
;start&quot; ;&#39; startling.txt<br>&gt;&gt;&gt; user@mbook:~\$ perl -nE &#=
39;print if /&quot;star&quot;/ .. /&quot;start&quot;/ ;&#39; startling.txt<=
br>&gt;&gt;&gt; user@mbook:~\$ perl -nE &#39;print if /star/ .. /start/ ;&#3=
9; startling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt;=
startl<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; st=
artling<br>&gt;&gt;&gt; user@mbook:~\$ raku -ne &#39;.put if &quot;star&quot=
; ff &quot;start&quot; ;&#39; startling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt=
;&gt; start<br>&gt;&gt;&gt; user@mbook:~\$ raku -ne &#39;.put if /&quot;star=
&quot;/ ff /&quot;start&quot;/ ;&#39; startling.txt<br>&gt;&gt;&gt; star<br=
>&gt;&gt;&gt; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; startli<br>&gt;&=
gt;&gt; startlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;&gt; user@mbook:~\$ ra=
ku -ne &#39;.put if /star/ ff /start/ ;&#39; startling.txt<br>&gt;&gt;&gt; =
star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; startli<b=
r>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;&gt; user@mboo=
k:~\$<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; I&#39;m all in favor of improving the =
&quot;ff&quot; and &quot;fff&quot; functions in Raku<br>&gt;&gt;&gt; over t=
heir Perl5 counterparts, but I&#39;m hoping to gain a better<br>&gt;&gt;&gt=
; (mnemonic?) way of remembering the expected return values with literal<br=
>&gt;&gt;&gt; vs regex arguments.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Any assis=
tance appreciated, Bill.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br=
>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; On Sun, Jul 2=
6, 2020 at 10:04 AM Larry Wall &lt;<a href=3D"mailto:larry@wall.org" target=
=3D"_blank">larry@wall.org</a>&gt; wrote:<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&=
gt; &gt; On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:<br>&=
gt;&gt;&gt; &gt; : In the above two cases ff and fff would behave identical=
ly.<br>&gt;&gt;&gt; &gt; :<br>&gt;&gt;&gt; &gt; : The difference shines whe=
n the beginning marker can look like the end<br>&gt;&gt;&gt; &gt; : marker.=
<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; The way I think of it is this: =
=C2=A0You come to the end of &quot;ff&quot; sooner, so you<br>&gt;&gt;&gt; =
&gt; do the end test immediately after passing the start test.=C2=A0 You co=
me to the<br>&gt;&gt;&gt; &gt; end of &quot;fff&quot; later, so the end tes=
t is delayed to the next iteration from<br>&gt;&gt;&gt; &gt; the start test=
.. =C2=A0(Same mnemonic for .. and ... in Perl, by the way, since<br>&gt;&gt=
;&gt; &gt; ff and fff were modeled on .. and ... (in their scalar form), bu=
t we stole<br>&gt;&gt;&gt; &gt; .. and ... in Raku for ranges and sequences=
so we needed something else.)<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; I =
suppose if you&#39;re musical you can come up with mnemonics based on &quot=
;fff&quot;<br>&gt;&gt;&gt; &gt; being louder than &quot;ff&quot;, so it ech=
oes longer before it stops... =C2=A0:)<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt;=
&gt; Larry</div>
</blockquote></div>

--00000000000092048205abe9055d--
```
 0
not
8/2/2020 6:16:20 PM
```--00000000000016fa9705abeb7e6d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Issue golf, ff is always evaluating its RHS

\$ raku -e 'say "With ff: ";say ( 1..5 ).grep({False ff .say}); say "With
fff: ";say ( 1..5 ).grep({False fff .say});'
With ff:
1
2
3
4
5
()
With fff:
()

-y

On Sun, Aug 2, 2020 at 2:16 PM yary <not.com@gmail.com> wrote:

> tl;dr: is this a Rakudo issue?
>
> ooh a puzzle =F0=9F=98=80 why do 'ff' and 'fff' give different results in=
this case?
> The start & end are disjoint, the \$++ should only run when the string tes=
t
> is true, so I expect 'ff' and 'fff' to behave the same also.
>
> Golfing a little
>
> \$ raku -e 'my @input=3Dqw<nope + B C D - 1 - no + E F - 2 3 - never never=
+
> G - 4 5 - hide>; \
> say "With ff:  ",@input.grep({(\$_ eq "+" && \$++ < 2) ff  (\$_ eq "-" && \$+=
+
> < 2)}); \
> say "With fff: ",@input.grep({(\$_ eq "+" && \$++ < 2) fff (\$_ eq "-" && \$+=
+
> < 2)});'
>
> With ff:  (+ B C D - + E F - 2 3 - never never + G - 4 5 - hide)
> With fff: (+ B C D - + E F -)
>
> With both of these, the flip-flop turns on with the first '+' and turns
> off with the first '-'
> With both of these, the 2nd '+' turns on the flip-flop.
> WIth 'ff', the flip-flop never turns off, with 'fff' the flip-flop turns
> off when it encounters the next '-'
>
> I wonder... let's have the end of the flip-flop say every time it runs
>
> raku -e 'my @input=3Dqw<nope + B C D - ?? - no + E F - !! ## - never neve=
r +
> G - %% && - hide>; \
> say "With ff: ";say @input.grep({(\$_ eq "+" && \$++ < 2) ff  ("checking
> \$_".say && \$_ eq "-" && say "increment to " ~ ++\$ )}); \
> say "With fff:";say @input.grep({(\$_ eq "+" && \$++ < 2) fff ("checking
> \$_".say && \$_ eq "-" && say "increment to " ~ ++\$ )});'
>
> With ff:
> checking nope
> checking +
> checking B
> checking C
> checking D
> checking -
> increment to 1
> checking ??
> checking -
> increment to 2
> checking no
> checking +
> checking E
> checking F
> checking -
> increment to 3
> checking !!
> checking ##
> checking -
> increment to 4
> checking never
> checking never
> checking +
> checking G
> checking -
> increment to 5
> checking %%
> checking &&
> checking -
> increment to 6
> checking hide
> (+ B C D - + E F -)
> With fff:
> checking B
> checking C
> checking D
> checking -
> increment to 1
> checking E
> checking F
> checking -
> increment to 2
> (+ B C D - + E F -)
>
> Hey gurus, why is the end check in 'ff' running so much more often than
> the end check of 'fff' ?
>
> ps. I had many weird errors, due to having "rake" installed, and having
> something autocorrect my "raku" command-line to "rake"!!!
>
> -y
>
>
> On Sat, Aug 1, 2020 at 10:06 PM William Michels <wjm1@caa.columbia.edu>
> wrote:
>
>> Hi Yary, Nice code!
>>
>> The general approach of using an anonymous counter is useful to me. Belo=
w
>> are  examples when I only want to recover the first one or two blocks of
>> text starting with "Start" and ending with "Mark" (nota bene: I took you=
r
>> example text and deleted the blank lines):
>>
>> user@book:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 1) fff (\$_ eq
>> "Mark" && \$++ < 1);' yary_ff_example2.txt
>> Start
>> hi print me
>> yes!
>> Mark
>> user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 1) ff (\$_ eq
>> "Mark" && \$++ < 1);' yary_ff_example2.txt
>> Start
>> hi print me
>> yes!
>> Mark
>> user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 2) fff (\$_ eq
>> "Mark" && \$++ < 2);' yary_ff_example2.txt
>> Start
>> hi print me
>> yes!
>> Mark
>> Start
>> We're back!
>> Mark
>> user@mbook:~\$ raku -ne ' say \$_ if (\$_ eq "Start" && \$++ < 2) ff (\$_ eq
>> "Mark" && \$++ < 2);' yary_ff_example2.txt
>> Start
>> hi print me
>> yes!
>> Mark
>> Start
>> We're back!
>> Mark
>> Still here!
>> Start
>> haha that Start does nothing
>> going to end it now
>> Mark
>> !bye bye don't see me!
>> user@mbook:~\$
>>
>> I guess I have to say--I'm still a little surprised by the last result
>> using the "ff" infix operator. I'd appreciate knowing why "ff" and "fff"
>> behave differently in the last two examples, since the beginning marker
>> doesn't look anything like the end marker (suggesting they should act
>> identically). Also, is there a simpler way to write the conditional?
>>
>> Thx, Bill.
>>
>>
>>
>> On Sat, Aug 1, 2020 at 4:04 PM yary <not.com@gmail.com> wrote:
>> >
>> > This made me want to try a contrived puzzle, use 'fff' to show things
>> between a "start" and 2nd "mark" line. That is, print any line below not
>> marked with "!" at the start
>> >
>> > \$ cat example.txt
>> >
>> > !ignore me
>> >
>> > Start
>> >
>> > hi print me
>> >
>> > yes!
>> >
>> > Mark
>> >
>> > still print me
>> >
>> > Mark
>> >
>> > !ignore this line
>> >
>> > !this line too
>> >
>> > Start
>> >
>> > We're back!
>> >
>> > Mark
>> >
>> > Still here!
>> >
>> > Start
>> >
>> > haha that Start does nothing
>> >
>> > going to end it now
>> >
>> > Mark
>> >
>> > !bye bye don't see me!
>> >
>> >
>> > Let's see...ooh that was easy!!
>> >
>> > raku -ne '.say if "Start" ff (\$_ eq "Mark" && ++\$ %% 2)' example.txt
>> >
>> >
>> > That increments the anonymous state variable \$ and then checks if it i=
s
>> divisible by 2, so that only every 2nd Mark returns True
>> >
>> > Don't know if I'll ever need it, fun to have it.
>> >
>> > -y
>> >
>> >
>> > On Tue, Jul 28, 2020 at 7:09 PM Brad Gilbert <b2gills@gmail.com> wrote=
:
>> >>
>> >> A regex doesn't have to match the entire string.
>> >>
>> >>     'abcd' ~~ / bc /
>> >>     # =EF=BD=A2bc=EF=BD=A3
>> >>
>> >> A string has to match exactly with the smart-match. (`ff` and `fff` d=
o
>> smart-match)
>> >>
>> >>     'abcd' ~~ 'bc' # False
>> >>     'abcd' ~~ 'abcd' # True
>> >>
>> >> A string inside of a regex only makes that a single atom, it does not
>> make it match like just a string.
>> >>
>> >>     'abcd' ~~ / 'bc' /
>> >>     # =EF=BD=A2bc=EF=BD=A3
>> >>
>> >>      'aBaBaB' ~~ / aB+ /
>> >>     =EF=BD=A2aB=EF=BD=A3
>> >>
>> >>      'aBaBaB' ~~ / "aB"+ /
>> >>     =EF=BD=A2aBaBaB=EF=BD=A3
>> >>
>> >> In fact a string inside of a regex doesn't do much more than square
>> brackets.
>> >>
>> >>      'aBaBaB' ~~ / [aB]+ /
>> >>     =EF=BD=A2aBaBaB=EF=BD=A3
>> >>
>> >> If you want the regex to match fully, add a beginning of string and
>> end of string marker.
>> >>
>> >>     'abcd' ~~ / ^ bc \$ /
>> >>     # Nil
>> >>
>> >>     'abcd' ~~ / ^ abcd \$ /
>> >>     # =EF=BD=A2abcd=EF=BD=A3
>> >>
>> >> ---
>> >>
>> >> Since `ff` can begin and end at the same time, the following is
>> turning on and off at almost every iteration of the loop after it starts=
..
>> >>
>> >>     \$ raku -ne '.put if /star {print q[on ]}/ ff /start {print q[off
>> ]}/ ;' startling.txt
>> >>     on star
>> >>     on off start
>> >>     on off startl
>> >>     on off startli
>> >>     on off startlin
>> >>     on off startling
>> >>
>> >> On Tue, Jul 28, 2020 at 1:43 PM William Michels <wjm1@caa.columbia.ed=
u>
>> wrote:
>> >>>
>> >>> Thank you, Brad and Larry, for explaining the "ff" and "fff" infix
>> >>> operators in Raku to me!
>> >>>
>> >>> I have to admit that I'm still fuzzy on the particulars between "ff"
>> >>> and "fff", since I am not familiar with the sed function. I can
>> >>> certainly understand how useful these functions could be to 'pull ou=
t
>> >>> all PGP signatures' from a file (which was the Perl5 example given i=
n
>> >>> the Oracle Linux Blog). So I can now  pull out the html "head" secti=
on
>> >>> from the page _ https://raku.org/fun/ _ (saved locally as file
>> >>> "fun.txt") using the following Raku code:
>> >>>
>> >>>     <meta charset=3D"utf-8">
>> >>>     <meta http-equiv=3D"X-UA-Compatible" content=3D"IE=3Dedge">
>> >>>     <meta name=3D"viewport" content=3D"width=3Ddevice-width,
>> initial-scale=3D1">
>> >>>     <title>Raku is optimized for fun!</title>
>> >>>
>> >>>
>> >>>     <link href=3D"/favicon.ico" rel=3D"shortcut icon" type=3D"image/=
x-icon">
t">
>> rel=3D"stylesheet">
>> >>>
>> >>> user@mbook:~\$
>> >>>
>> >>> What I'm less clear on is how the code below is functioning. I first
>> >>> print out file named "startling.txt" with 'cat':  it's supposed to
>> >>> stand in for a text delimited linewise by "header 1", "header 2", et=
c.
>> >>> After the 'cat' example, I show three examples with Perl(v5.26.3) an=
d
>> >>> three examples with Raku(2020.06), generally comparing literal vs
>> >>> regex arguments.
>> >>>
>> >>> The first two Perl5 examples returns nothing; the third Perl5 exampl=
e
>> >>> returns everything after the "star" line. For the Raku code, the
>> >>> 'DWIMmiest' output below is the first Raku example, which returns tw=
o
>> >>> lines, "star" and "start". This is what I expected/desired. But I'm
>> >>> not really understanding what's happening with the other 2 Raku
>> >>> examples (which return everything after the "star" line):
>> >>>
>> >>> user@mbook:~\$ cat startling.txt
>> >>> s
>> >>> st
>> >>> sta
>> >>> star
>> >>> start
>> >>> startl
>> >>> startli
>> >>> startlin
>> >>> startling
>> >>>
>> >>> user@mbook:~\$ perl -nE 'print if "star" .. "start" ;' startling.txt
>> >>> user@mbook:~\$ perl -nE 'print if /"star"/ .. /"start"/ ;'
>> startling.txt
>> >>> user@mbook:~\$ perl -nE 'print if /star/ .. /start/ ;' startling.txt
>> >>> star
>> >>> start
>> >>> startl
>> >>> startli
>> >>> startlin
>> >>> startling
>> >>> user@mbook:~\$ raku -ne '.put if "star" ff "start" ;' startling.txt
>> >>> star
>> >>> start
>> >>> user@mbook:~\$ raku -ne '.put if /"star"/ ff /"start"/ ;'
>> startling.txt
>> >>> star
>> >>> start
>> >>> startl
>> >>> startli
>> >>> startlin
>> >>> startling
>> >>> user@mbook:~\$ raku -ne '.put if /star/ ff /start/ ;' startling.txt
>> >>> star
>> >>> start
>> >>> startl
>> >>> startli
>> >>> startlin
>> >>> startling
>> >>> user@mbook:~\$
>> >>>
>> >>> I'm all in favor of improving the "ff" and "fff" functions in Raku
>> >>> over their Perl5 counterparts, but I'm hoping to gain a better
>> >>> (mnemonic?) way of remembering the expected return values with liter=
al
>> >>> vs regex arguments.
>> >>>
>> >>> Any assistance appreciated, Bill.
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> On Sun, Jul 26, 2020 at 10:04 AM Larry Wall <larry@wall.org> wrote:
>> >>> >
>> >>> > On Sat, Jul 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:
>> >>> > : In the above two cases ff and fff would behave identically.
>> >>> > :
>> >>> > : The difference shines when the beginning marker can look like th=
e
>> end
>> >>> > : marker.
>> >>> >
>> >>> > The way I think of it is this:  You come to the end of "ff" sooner=
,
>> so you
>> >>> > do the end test immediately after passing the start test.  You com=
e
>> to the
>> >>> > end of "fff" later, so the end test is delayed to the next
>> iteration from
>> >>> > the start test.  (Same mnemonic for .. and ... in Perl, by the way=
,
>> since
>> >>> > ff and fff were modeled on .. and ... (in their scalar form), but
>> we stole
>> >>> > .. and ... in Raku for ranges and sequences so we needed something
>> else.)
>> >>> >
>> >>> > I suppose if you're musical you can come up with mnemonics based o=
n
>> "fff"
>> >>> > being louder than "ff", so it echoes longer before it stops...  :)
>> >>> >
>> >>> > Larry
>>
>

--00000000000016fa9705abeb7e6d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">Issue golf, ff is always=C2=A0evaluating=
=C2=A0its RHS<div><br></div><div><div>\$ raku -e &#39;say &quot;With ff: &qu=
ot;;say ( 1..5 ).grep({False ff .say}); say &quot;With fff: &quot;;say ( 1.=
..5 ).grep({False fff .say});&#39;</div><div>With ff:=C2=A0</div><div>1</div=
><div>2</div><div>3</div><div>4</div><div>5</div><div>()</div><div>With fff=
:=C2=A0</div><div>()</div></div><div><br></div><div><br clear=3D"all"><div>=
<div dir=3D"ltr" class=3D"gmail_signature">-y<br></div></div><br></div></di=
v></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr=
">On Sun, Aug 2, 2020 at 2:16 PM yary &lt;<a href=3D"mailto:not.com@gmail.c=
om">not.com@gmail.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_qu=
ote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-st=
ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><d=
iv>tl;dr: is this a Rakudo issue?</div><div dir=3D"ltr"><br></div><div dir=
=3D"ltr">ooh a puzzle =F0=9F=98=80 why do &#39;ff&#39; and &#39;fff&#39; gi=
ve different results in this case? The start &amp; end are disjoint, the=C2=
=A0\$++ should only run when the string test is true, so I expect &#39;ff&#3=
9; and &#39;fff&#39; to behave the same also.<div><br></div><div>Golfing a =
little</div><div><br></div><div><div>\$ raku -e &#39;my @input=3Dqw&lt;nope =
+ B C D - 1 - no + E F - 2 3 - never never + G - 4 5 - hide&gt;; \</div><di=
v>say &quot;With ff: =C2=A0&quot;,@input.grep({(\$_ eq &quot;+&quot; &amp;&a=
mp; \$++ &lt; 2) ff =C2=A0(\$_ eq &quot;-&quot; &amp;&amp; \$++ &lt; 2)}); \</=
div><div>say &quot;With fff: &quot;,@input.grep({(\$_ eq &quot;+&quot; &amp;=
&amp; \$++ &lt; 2) fff (\$_ eq &quot;-&quot; &amp;&amp; \$++ &lt; 2)});&#39;</=
div></div><div><br></div><div><div><font face=3D"monospace">With ff: =C2=A0=
(+ B C D - + E F - 2 3 - never never + G - 4 5 - hide)</font></div><div><fo=
nt face=3D"monospace">With fff: (+ B C D - + E F -)</font></div></div><div>=
<br></div><div>With both of these, the flip-flop turns on with the first &#=
39;+&#39; and turns off with the first &#39;-&#39;</div><div>With both of t=
hese, the 2nd &#39;+&#39; turns on the flip-flop.</div><div>WIth &#39;ff&#3=
9;, the flip-flop never turns off, with &#39;fff&#39; the flip-flop turns o=
ff when it encounters the next &#39;-&#39;</div><div><br></div><div>I wonde=
r... let&#39;s have the end of the flip-flop say every time it runs</div><d=
iv><br></div><div><div>raku -e &#39;my @input=3Dqw&lt;nope + B C D - ?? - n=
o + E F - !! ## - never never + G - %% &amp;&amp; - hide&gt;; \</div><div>s=
ay &quot;With ff: &quot;;say @input.grep({(\$_ eq &quot;+&quot; &amp;&amp; \$=
++ &lt; 2) ff =C2=A0(&quot;checking \$_&quot;.say &amp;&amp; \$_ eq &quot;-&q=
uot; &amp;&amp; say &quot;increment to &quot; ~ ++\$ )}); \</div><div>say &q=
uot;With fff:&quot;;say @input.grep({(\$_ eq &quot;+&quot; &amp;&amp; \$++ &l=
t; 2) fff (&quot;checking \$_&quot;.say &amp;&amp; \$_ eq &quot;-&quot; &amp;=
&amp; say &quot;increment to &quot; ~ ++\$ )});&#39;</div><div><br></div><di=
v><font face=3D"monospace">With ff:=C2=A0</font></div><div><font face=3D"mo=
nospace">checking nope</font></div><div><font face=3D"monospace">checking +=
</font></div><div><font face=3D"monospace">checking B</font></div><div><fon=
t face=3D"monospace">checking C</font></div><div><font face=3D"monospace">c=
hecking D</font></div><div><font face=3D"monospace">checking -</font></div>=
<div><font face=3D"monospace">increment to 1</font></div><div><font face=3D=
"monospace">checking ??</font></div><div><font face=3D"monospace">checking =
-</font></div><div><font face=3D"monospace">increment to 2</font></div><div=
><font face=3D"monospace">checking no</font></div><div><font face=3D"monosp=
ace">checking +</font></div><div><font face=3D"monospace">checking E</font>=
</div><div><font face=3D"monospace">checking F</font></div><div><font face=
=3D"monospace">checking -</font></div><div><font face=3D"monospace">increme=
nt to 3</font></div><div><font face=3D"monospace">checking !!</font></div><=
div><font face=3D"monospace">checking ##</font></div><div><font face=3D"mon=
ospace">checking -</font></div><div><font face=3D"monospace">increment to 4=
</font></div><div><font face=3D"monospace">checking never</font></div><div>=
<font face=3D"monospace">checking never</font></div><div><font face=3D"mono=
space">checking +</font></div><div><font face=3D"monospace">checking G</fon=
t></div><div><font face=3D"monospace">checking -</font></div><div><font fac=
e=3D"monospace">increment to 5</font></div><div><font face=3D"monospace">ch=
ecking %%</font></div><div><font face=3D"monospace">checking &amp;&amp;</fo=
nt></div><div><font face=3D"monospace">checking -</font></div><div><font fa=
ce=3D"monospace">increment to 6</font></div><div><font face=3D"monospace">c=
hecking hide</font></div><div><font face=3D"monospace">(+ B C D - + E F -)<=
/font></div><div><font face=3D"monospace">With fff:</font></div><div><font =
face=3D"monospace">checking B</font></div><div><font face=3D"monospace">che=
cking C</font></div><div><font face=3D"monospace">checking D</font></div><d=
iv><font face=3D"monospace">checking -</font></div><div><font face=3D"monos=
pace">increment to 1</font></div><div><font face=3D"monospace">checking E</=
font></div><div><font face=3D"monospace">checking F</font></div><div><font =
face=3D"monospace">checking -</font></div><div><font face=3D"monospace">inc=
rement to 2</font></div><div><font face=3D"monospace">(+ B C D - + E F -)</=
font></div></div><div><br></div><div>Hey gurus, why is the end check in &#3=
9;ff&#39; running so much more often than the end check of &#39;fff&#39; ?<=
/div><div><br></div><div><div>ps. I had many weird errors, due to having &q=
uot;rake&quot; installed, and having something autocorrect my &quot;raku&qu=
ot; command-line to &quot;rake&quot;!!!<br><div><br clear=3D"all"><div><div=
dir=3D"ltr">-y<br></div></div><br></div></div></div></div></div></div></di=
v></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmai=
l_attr">On Sat, Aug 1, 2020 at 10:06 PM William Michels &lt;<a href=3D"mail=
to:wjm1@caa.columbia.edu" target=3D"_blank">wjm1@caa.columbia.edu</a>&gt; w=
rote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb=
(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>Hi Yary, Nice code! <=
br></div><div><br></div><div>The general approach of using an anonymous cou=
nter is useful to me. Below are =C2=A0examples when I only want to recover =
the first one or two blocks of text starting with &quot;Start&quot; and end=
ing with &quot;Mark&quot; (nota bene: I took your example text and deleted =
the blank lines):</div><br>user@book:~\$ raku -ne &#39; say \$_ if (\$_ eq &qu=
ot;Start&quot; &amp;&amp; \$++ &lt; 1) fff (\$_ eq &quot;Mark&quot; &amp;&amp=
; \$++ &lt; 1);&#39; yary_ff_example2.txt<br>Start<br>hi print me<br>yes!<br=
>Mark<br>user@mbook:~\$ raku -ne &#39; say \$_ if (\$_ eq &quot;Start&quot; &a=
mp;&amp; \$++ &lt; 1) ff (\$_ eq &quot;Mark&quot; &amp;&amp; \$++ &lt; 1);&#39=
; yary_ff_example2.txt<br>Start<br>hi print me<br>yes!<br>Mark<br>user@mboo=
k:~\$ raku -ne &#39; say \$_ if (\$_ eq &quot;Start&quot; &amp;&amp; \$++ &lt; =
2) fff (\$_ eq &quot;Mark&quot; &amp;&amp; \$++ &lt; 2);&#39; yary_ff_example=
2.txt<br>Start<br>hi print me<br>yes!<br>Mark<br>Start<br>We&#39;re back!<b=
r>Mark<br>user@mbook:~\$ raku -ne &#39; say \$_ if (\$_ eq &quot;Start&quot; &=
amp;&amp; \$++ &lt; 2) ff (\$_ eq &quot;Mark&quot; &amp;&amp; \$++ &lt; 2);&#3=
9; yary_ff_example2.txt<br>Start<br>hi print me<br>yes!<br>Mark<br>Start<br=
>We&#39;re back!<br>Mark<br>Still here!<br>Start<br>haha that Start does no=
thing<br>going to end it now<br>Mark<br>!bye bye don&#39;t see me!<br><div>=
user@mbook:~\$</div><div><br></div><div>I guess I have to say--I&#39;m still=
a little surprised by the last result using the &quot;ff&quot; infix opera=
tor. I&#39;d appreciate knowing why &quot;ff&quot; and &quot;fff&quot; beha=
ve differently in the last two examples, since the beginning marker doesn&#=
39;t look anything like the end marker (suggesting they should act identica=
lly). Also, is there a simpler way to write the conditional?<br></div><div>=
<br></div><div>Thx, Bill. <br></div><div><br></div><div><br></div><br>On Sa=
t, Aug 1, 2020 at 4:04 PM yary &lt;<a href=3D"mailto:not.com@gmail.com" tar=
e want to try a contrived puzzle, use &#39;fff&#39; to show things between =
a &quot;start&quot; and 2nd &quot;mark&quot; line. That is, print any line =
below not marked with &quot;!&quot; at the start<br>&gt;<br>&gt; \$ cat exam=
ple.txt<br>&gt;<br>&gt; !ignore me<br>&gt;<br>&gt; Start<br>&gt;<br>&gt; hi=
print me<br>&gt;<br>&gt; yes!<br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; still p=
rint me<br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; !ignore this line<br>&gt;<br>&=
gt; !this line too<br>&gt;<br>&gt; Start<br>&gt;<br>&gt; We&#39;re back!<br=
>&gt;<br>&gt; Mark<br>&gt;<br>&gt; Still here!<br>&gt;<br>&gt; Start<br>&gt=
;<br>&gt; haha that Start does nothing<br>&gt;<br>&gt; going to end it now<=
br>&gt;<br>&gt; Mark<br>&gt;<br>&gt; !bye bye don&#39;t see me!<br>&gt;<br>=
&gt;<br>&gt; Let&#39;s see...ooh that was easy!!<br>&gt;<br>&gt; raku -ne &=
#39;.say if &quot;Start&quot; ff (\$_ eq &quot;Mark&quot; &amp;&amp; ++\$ %% =
2)&#39; example.txt<br>&gt;<br>&gt;<br>&gt; That increments the anonymous s=
tate variable \$ and then checks if it is divisible by 2, so that only every=
2nd Mark returns True<br>&gt;<br>&gt; Don&#39;t know if I&#39;ll ever need=
it, fun to have it.<br>&gt;<br>&gt; -y<br>&gt;<br>&gt;<br>&gt; On Tue, Jul=
28, 2020 at 7:09 PM Brad Gilbert &lt;<a href=3D"mailto:b2gills@gmail.com" =
target=3D"_blank">b2gills@gmail.com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; =
A regex doesn&#39;t have to match the entire string.<br>&gt;&gt;<br>&gt;&gt=
; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / bc /<br>&gt;&gt; =C2=A0 =C2=A0 # =EF=BD=
=A2bc=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; A string has to match exactly with t=
he smart-match. (`ff` and `fff` do smart-match)<br>&gt;&gt;<br>&gt;&gt; =C2=
=A0 =C2=A0 &#39;abcd&#39; ~~ &#39;bc&#39; # False<br>&gt;&gt; =C2=A0 =C2=A0=
&#39;abcd&#39; ~~ &#39;abcd&#39; # True<br>&gt;&gt;<br>&gt;&gt; A string i=
nside of a regex only makes that a single atom, it does not make it match l=
ike just a string.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ =
/ &#39;bc&#39; /<br>&gt;&gt; =C2=A0 =C2=A0 # =EF=BD=A2bc=EF=BD=A3<br>&gt;&g=
t;<br>&gt;&gt; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / aB+ /<br>&gt;&gt; =
=C2=A0 =C2=A0 =EF=BD=A2aB=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 =
=C2=A0&#39;aBaBaB&#39; ~~ / &quot;aB&quot;+ /<br>&gt;&gt; =C2=A0 =C2=A0 =EF=
=BD=A2aBaBaB=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; In fact a string inside of a =
regex doesn&#39;t do much more than square brackets.<br>&gt;&gt;<br>&gt;&gt=
; =C2=A0 =C2=A0 =C2=A0&#39;aBaBaB&#39; ~~ / [aB]+ /<br>&gt;&gt; =C2=A0 =C2=
=A0 =EF=BD=A2aBaBaB=EF=BD=A3<br>&gt;&gt;<br>&gt;&gt; If you want the regex =
to match fully, add a beginning of string and end of string marker.<br>&gt;=
&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / ^ bc \$ /<br>&gt;&gt; =C2=
=A0 =C2=A0 # Nil<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 &#39;abcd&#39; ~~ / =
^ abcd \$ /<br>&gt;&gt; =C2=A0 =C2=A0 # =EF=BD=A2abcd=EF=BD=A3<br>&gt;&gt;<b=
r>&gt;&gt; ---<br>&gt;&gt;<br>&gt;&gt; Since `ff` can begin and end at the =
same time, the following is turning on and off at almost every iteration of=
the loop after it starts.<br>&gt;&gt;<br>&gt;&gt; =C2=A0 =C2=A0 \$ raku -ne=
&#39;.put if /star {print q[on ]}/ ff /start {print q[off ]}/ ;&#39; start=
ling.txt<br>&gt;&gt; =C2=A0 =C2=A0 on star<br>&gt;&gt; =C2=A0 =C2=A0 on off=
start<br>&gt;&gt; =C2=A0 =C2=A0 on off startl<br>&gt;&gt; =C2=A0 =C2=A0 on=
off startli<br>&gt;&gt; =C2=A0 =C2=A0 on off startlin<br>&gt;&gt; =C2=A0 =
=C2=A0 on off startling<br>&gt;&gt;<br>&gt;&gt; On Tue, Jul 28, 2020 at 1:4=
3 PM William Michels &lt;<a href=3D"mailto:wjm1@caa.columbia.edu" target=3D=
"_blank">wjm1@caa.columbia.edu</a>&gt; wrote:<br>&gt;&gt;&gt;<br>&gt;&gt;&g=
t; Thank you, Brad and Larry, for explaining the &quot;ff&quot; and &quot;f=
ff&quot; infix<br>&gt;&gt;&gt; operators in Raku to me!<br>&gt;&gt;&gt;<br>=
&gt;&gt;&gt; I have to admit that I&#39;m still fuzzy on the particulars be=
tween &quot;ff&quot;<br>&gt;&gt;&gt; and &quot;fff&quot;, since I am not fa=
miliar with the sed function. I can<br>&gt;&gt;&gt; certainly understand ho=
w useful these functions could be to &#39;pull out<br>&gt;&gt;&gt; all PGP =
signatures&#39; from a file (which was the Perl5 example given in<br>&gt;&g=
t;&gt; the Oracle Linux Blog). So I can now =C2=A0pull out the html &quot;h=
ead&quot; section<br>&gt;&gt;&gt; from the page _ <a href=3D"https://raku.o=
rg/fun/" target=3D"_blank">https://raku.org/fun/</a> _ (saved locally as fi=
le<br>&gt;&gt;&gt; &quot;fun.txt&quot;) using the following Raku code:<br>&=
gt;&gt;&gt;<br>&gt;&gt;&gt; user@mbook:~\$ raku -ne &#39;.put if Q[&lt;head&=
gt;&gt; =C2=A0 =C2=A0 &lt;meta charset=3D&quot;utf-8&quot;&gt;<br>&gt;&gt;&=
gt; =C2=A0 =C2=A0 &lt;meta http-equiv=3D&quot;X-UA-Compatible&quot; content=
=3D&quot;IE=3Dedge&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;meta name=3D=
&quot;viewport&quot; content=3D&quot;width=3Ddevice-width, initial-scale=3D=
1&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt;title&gt;Raku is optimized fo=
r fun!&lt;/title&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; =C2=A0=
quot; type=3D&quot;image/x-icon&quot;&gt;<br>&gt;&gt;&gt; =C2=A0 =C2=A0 &lt=
rap/css/bootstrap-theme.min.css&quot; rel=3D&quot;stylesheet&quot;&gt;<br>&=
gt;&gt;&gt; =C2=A0 =C2=A0 &lt;link href=3D&quot;/style.css?v=3D1&quot; rel=
<br>&gt;&gt;&gt; user@mbook:~\$<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; What I&#39;m=
less clear on is how the code below is functioning. I first<br>&gt;&gt;&gt=
; print out file named &quot;startling.txt&quot; with &#39;cat&#39;: =C2=A0=
it&#39;s supposed to<br>&gt;&gt;&gt; stand in for a text delimited linewise=
the &#39;cat&#39; example, I show three examples with Perl(v5.26.3) and<br>=
&gt;&gt;&gt; three examples with Raku(2020.06), generally comparing literal=
vs<br>&gt;&gt;&gt; regex arguments.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; The fi=
rst two Perl5 examples returns nothing; the third Perl5 example<br>&gt;&gt;=
&gt; returns everything after the &quot;star&quot; line. For the Raku code,=
the<br>&gt;&gt;&gt; &#39;DWIMmiest&#39; output below is the first Raku exa=
mple, which returns two<br>&gt;&gt;&gt; lines, &quot;star&quot; and &quot;s=
tart&quot;. This is what I expected/desired. But I&#39;m<br>&gt;&gt;&gt; no=
t really understanding what&#39;s happening with the other 2 Raku<br>&gt;&g=
t;&gt; examples (which return everything after the &quot;star&quot; line):<=
br>&gt;&gt;&gt;<br>&gt;&gt;&gt; user@mbook:~\$ cat startling.txt<br>&gt;&gt;=
&gt; s<br>&gt;&gt;&gt; st<br>&gt;&gt;&gt; sta<br>&gt;&gt;&gt; star<br>&gt;&=
gt;&gt; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt=
; startlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; user@m=
book:~\$ perl -nE &#39;print if &quot;star&quot; .. &quot;start&quot; ;&#39;=
startling.txt<br>&gt;&gt;&gt; user@mbook:~\$ perl -nE &#39;print if /&quot;=
star&quot;/ .. /&quot;start&quot;/ ;&#39; startling.txt<br>&gt;&gt;&gt; use=
r@mbook:~\$ perl -nE &#39;print if /star/ .. /start/ ;&#39; startling.txt<br=
>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;=
&gt; startli<br>&gt;&gt;&gt; startlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;=
&gt; user@mbook:~\$ raku -ne &#39;.put if &quot;star&quot; ff &quot;start&qu=
ot; ;&#39; startling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start<br>&gt;=
&gt;&gt; user@mbook:~\$ raku -ne &#39;.put if /&quot;star&quot;/ ff /&quot;s=
tart&quot;/ ;&#39; startling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt; start=
<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt; startlin<br=
>&gt;&gt;&gt; startling<br>&gt;&gt;&gt; user@mbook:~\$ raku -ne &#39;.put if=
/star/ ff /start/ ;&#39; startling.txt<br>&gt;&gt;&gt; star<br>&gt;&gt;&gt=
; start<br>&gt;&gt;&gt; startl<br>&gt;&gt;&gt; startli<br>&gt;&gt;&gt; star=
tlin<br>&gt;&gt;&gt; startling<br>&gt;&gt;&gt; user@mbook:~\$<br>&gt;&gt;&gt=
;<br>&gt;&gt;&gt; I&#39;m all in favor of improving the &quot;ff&quot; and =
&quot;fff&quot; functions in Raku<br>&gt;&gt;&gt; over their Perl5 counterp=
arts, but I&#39;m hoping to gain a better<br>&gt;&gt;&gt; (mnemonic?) way o=
f remembering the expected return values with literal<br>&gt;&gt;&gt; vs re=
gex arguments.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; Any assistance appreciated, =
Bill.<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt;<br>&g=
t;&gt;&gt;<br>&gt;&gt;&gt;<br>&gt;&gt;&gt; On Sun, Jul 26, 2020 at 10:04 AM=
Larry Wall &lt;<a href=3D"mailto:larry@wall.org" target=3D"_blank">larry@w=
all.org</a>&gt; wrote:<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; On Sat, Ju=
l 25, 2020 at 04:32:02PM -0500, Brad Gilbert wrote:<br>&gt;&gt;&gt; &gt; : =
In the above two cases ff and fff would behave identically.<br>&gt;&gt;&gt;=
&gt; :<br>&gt;&gt;&gt; &gt; : The difference shines when the beginning mar=
ker can look like the end<br>&gt;&gt;&gt; &gt; : marker.<br>&gt;&gt;&gt; &g=
t;<br>&gt;&gt;&gt; &gt; The way I think of it is this: =C2=A0You come to th=
e end of &quot;ff&quot; sooner, so you<br>&gt;&gt;&gt; &gt; do the end test=
immediately after passing the start test.=C2=A0 You come to the<br>&gt;&gt=
;&gt; &gt; end of &quot;fff&quot; later, so the end test is delayed to the =
next iteration from<br>&gt;&gt;&gt; &gt; the start test. =C2=A0(Same mnemon=
ic for .. and ... in Perl, by the way, since<br>&gt;&gt;&gt; &gt; ff and ff=
f were modeled on .. and ... (in their scalar form), but we stole<br>&gt;&g=
t;&gt; &gt; .. and ... in Raku for ranges and sequences so we needed someth=
ing else.)<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; I suppose if you&#39;r=
e musical you can come up with mnemonics based on &quot;fff&quot;<br>&gt;&g=
t;&gt; &gt; being louder than &quot;ff&quot;, so it echoes longer before it=
stops... =C2=A0:)<br>&gt;&gt;&gt; &gt;<br>&gt;&gt;&gt; &gt; Larry</div>
</blockquote></div>
</blockquote></div>

--00000000000016fa9705abeb7e6d--
```
 0
not
8/2/2020 9:13:13 PM
```--0000000000003b824105abebe54c
Content-Type: text/plain; charset="UTF-8"

On Sun, Aug 2, 2020 at 11:14 PM yary <not.com@gmail.com> wrote:

> Issue golf, ff is always evaluating its RHS
>
> \$ raku -e 'say "With ff: ";say ( 1..5 ).grep({False ff .say}); say "With
> fff: ";say ( 1..5 ).grep({False fff .say});'
> With ff:
> 1
> 2
> 3
> 4
> 5
> ()
> With fff:
> ()
>

I haven't looked much at Raku since it was Perl6, but for comparison,
here's some Perl 5:

\$ perl -E 'say "With ..: ";say grep {/nope/ .. say} 1..5; say "With ...:
";say grep {/nope/ ... say} 1..5;'
With ..:

With ...:

Eirik

--0000000000003b824105abebe54c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">On Sun, Aug 2, 2020 at 11:14 PM yary &lt;=
<a href=3D"mailto:not.com@gmail.com">not.com@gmail.com</a>&gt; wrote:<br></=
div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex"><div dir=3D"ltr"><div dir=3D"ltr">Issue golf, ff is always=C2=A0evalu=
ating=C2=A0its RHS<div><br></div><div><div>\$ raku -e &#39;say &quot;With ff=
: &quot;;say ( 1..5 ).grep({False ff .say}); say &quot;With fff: &quot;;say=
( 1..5 ).grep({False fff .say});&#39;</div><div>With ff:=C2=A0</div><div>1=
</div><div>2</div><div>3</div><div>4</div><div>5</div><div>()</div><div>Wit=
h fff:=C2=A0</div><div>()</div></div></div></div></blockquote><div><br></di=
v><div>=C2=A0 I haven&#39;t looked much at Raku since it was Perl6, but for=
comparison, here&#39;s some Perl 5:</div><div><br></div><div>\$ perl -E &#3=
9;say &quot;With ..: &quot;;say grep {/nope/ .. say} 1..5; say &quot;With .=
...: &quot;;say grep {/nope/ ... say} 1..5;&#39;<br>With ..: <br><br>With ..=
..: <br><br></div><div><br></div><div>Eirik<br></div></div></div>

--0000000000003b824105abebe54c--
```
 0
Eirik
8/2/2020 9:42:03 PM
```--000000000000537f2805ac00114e
Content-Type: text/plain; charset="UTF-8"

I opened a Raku ticket https://github.com/rakudo/rakudo/issues/3839
-y

On Sun, Aug 2, 2020 at 5:42 PM Eirik Berg Hanssen <
Eirik-Berg.Hanssen@allverden.no> wrote:

> On Sun, Aug 2, 2020 at 11:14 PM yary <not.com@gmail.com> wrote:
>
>> Issue golf, ff is always evaluating its RHS
>>
>> \$ raku -e 'say "With ff: ";say ( 1..5 ).grep({False ff .say}); say "With
>> fff: ";say ( 1..5 ).grep({False fff .say});'
>> With ff:
>> 1
>> 2
>> 3
>> 4
>> 5
>> ()
>> With fff:
>> ()
>>
>
>   I haven't looked much at Raku since it was Perl6, but for comparison,
> here's some Perl 5:
>
> \$ perl -E 'say "With ..: ";say grep {/nope/ .. say} 1..5; say "With ...:
> ";say grep {/nope/ ... say} 1..5;'
> With ..:
>
> With ...:
>
>
> Eirik
>

--000000000000537f2805ac00114e
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">I opened a Raku ticket <a href=3D"https:/=
/github.com/rakudo/rakudo/issues/3839">https://github.com/rakudo/rakudo/iss=
ues/3839</a><br clear=3D"all"><div><div dir=3D"ltr" class=3D"gmail_signatur=
e">-y<br></div></div><br></div></div><br><div class=3D"gmail_quote"><div di=
r=3D"ltr" class=3D"gmail_attr">On Sun, Aug 2, 2020 at 5:42 PM Eirik Berg Ha=
nssen &lt;<a href=3D"mailto:Eirik-Berg.Hanssen@allverden.no">Eirik-Berg.Han=
ssen@allverden.no</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote"=
style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:=
><div dir=3D"ltr">On Sun, Aug 2, 2020 at 11:14 PM yary &lt;<a href=3D"mailt=
o:not.com@gmail.com" target=3D"_blank">not.com@gmail.com</a>&gt; wrote:<br>=
</div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D=
"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;bor=
=3D"ltr">Issue golf, ff is always=C2=A0evaluating=C2=A0its RHS<div><br></di=
v><div><div>\$ raku -e &#39;say &quot;With ff: &quot;;say ( 1..5 ).grep({Fal=
se ff .say}); say &quot;With fff: &quot;;say ( 1..5 ).grep({False fff .say}=
);&#39;</div><div>With ff:=C2=A0</div><div>1</div><div>2</div><div>3</div><=
div>4</div><div>5</div><div>()</div><div>With fff:=C2=A0</div><div>()</div>=
</div></div></div></blockquote><div><br></div><div>=C2=A0 I haven&#39;t loo=
ked much at Raku since it was Perl6, but for comparison, here&#39;s some Pe=
rl 5:</div><div><br></div><div>\$ perl -E &#39;say &quot;With ..: &quot;;say=
grep {/nope/ .. say} 1..5; say &quot;With ...: &quot;;say grep {/nope/ ...=
say} 1..5;&#39;<br>With ..: <br><br>With ...: <br><br></div><div><br></div=
><div>Eirik<br></div></div></div>
</blockquote></div>

--000000000000537f2805ac00114e--
```
 0
not
8/3/2020 9:46:03 PM