Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^3: Generate the perl sequence 1, 11, 111, ....

by blazar (Canon)
on Oct 11, 2008 at 11:29 UTC ( #716586=note: print w/replies, xml ) Need Help??

in reply to Re^2: Generate the perl sequence 1, 11, 111, ....
in thread Generate the perl sequence 1, 11, 111, ....

where that just says "make an arbitrarily long list of 1's and reduce them using concatenation (the ~ operator), returning partial results in a list".

I personally believe that I need some clarifications: I understand clearly that the backslash implements the "returning partial results" thingie, but I am not sure about is semantics. In particular, is it a metaoperator modifying any binary operator, and if so, how? Or is really [\ ] a distinct metaoperator wrt [ ], with the former being the "reduction returning partial results" and the latter simply "reduction?"

If you can't understand the incipit, then please check the IPB Campaign.

Replies are listed 'Best First'.
Re^4: Generate the perl sequence 1, 11, 111, ....
by moritz (Cardinal) on Oct 11, 2008 at 12:03 UTC
    Use the source, Luke.
    regex prefix_circumfix_meta_operator:reduce (--> List_prefix) { $<s> = ( '[' [ | <op=infix> ']' [''|<?>] | <op=infix_prefix_meta_operator> ']' [''|<?>] | <op=infix_circumfix_meta_operator> ']' [''|<?>] | \\<op=infix> ']' [''|<?>] | \\<op=infix_prefix_meta_operator> ']' [''|<?>] | \\<op=infix_circumfix_meta_operator> ']' [''|<?>] ] ) <?before \s | '(' > ...

    So [\ is really a handled specially.

      Note however that the main reason those are handled separately is to deal with certain limitations in the autolexer. There's no reason the underlying reductions can't share most of their code, except for the bit that decides whether to return partial results.
      Or if you're not inclined to read the source, you can examine the match tree:

      I personally believe that this would indeed better be the case. Actually, I have eventually obtained an account on feather courtesy of Juerd and I wanted to experiment there. But I'm stuck again: what package is the STD5_dump_match script supposed to be part of, and where can I find it to the point of trying it myself? I presume that it's pugs. But then I expected to find it somewhere in ~audreyt/pugs given that the pugs executable itself on that machine is a link into that directory - however that doesn't seem to be the case. Or it may be a matter of permissions; whatever: any idea?

      Sorry for being so dumb: if nothing else I hope this may help some other people out there!

      If you can't understand the incipit, then please check the IPB Campaign.

        Sorry to the OP for going so far off-topic...

        You need to grab a copy of the pugs repository. In that repo you'll find the directory src/perl6/, in which you can find and STD5_dump_match.

        (If you take somebody else's checkout of the pugs repository please copy the perl6/ folder to your home directory, because you need write accessing for the lex cache).

        In that dir, type make, then you can use perl STD5_dump_match $file to print out a match tree.

        (You need a perl 5.10.0 in /usr/local/perl to run this, along with a few modules like re::engine::TRE, JSON::XS and Moose. I'll try to install all the dependencies on feather now.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://716586]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2018-09-19 16:52 GMT
Find Nodes?
    Voting Booth?
    Eventually, "covfefe" will come to mean:

    Results (167 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!