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

2020-08-03 Thread yary
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.hans...@allverden.no> wrote: > On Sun, Aug 2, 2020 at 11:14 PM yary wrote: > >> Issue golf, ff is always evaluating its RHS >> >> $ raku -e 'say "With ff: ";say

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

2020-08-02 Thread Eirik Berg Hanssen
On Sun, Aug 2, 2020 at 11:14 PM yary 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

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

2020-08-02 Thread yary
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 wrote: > tl;dr: is this a Rakudo issue? > > ooh a

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

2020-08-02 Thread yary
tl;dr: is this a Rakudo issue? ooh a puzzle  why do 'ff' and 'fff' give different results in this 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=qw; \ say "With

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

2020-08-01 Thread William Michels via perl6-users
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:~$

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

2020-08-01 Thread yary
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

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

2020-07-28 Thread Brad Gilbert
A regex doesn't have to match the entire string. 'abcd' ~~ / bc / # 「bc」 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

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

2020-07-28 Thread William Michels via perl6-users
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

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

2020-07-26 Thread Larry Wall
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

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

2020-07-25 Thread Brad Gilbert
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

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

2020-07-25 Thread William Michels via perl6-users
Hello, I'm trying to learn the "ff" (flipflop) infix operator, generally taking examples from the docs (below): https://docs.raku.org/routine/ff I tried adding in an "m:1st" adverb and an "m:2nd" adverb, but the output isn't what I expect with the "m:2nd" adverb (examples #3 and #5): say "\n1.