Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
First, thanks for taking the time to do this! The way you broke out the examples is great. It's a much better format for meditation than my original linear flow.

Second, here's a patch that adds seq_concat, which is almost identical to seq_series. (In fact, the patch redefines the latter in terms of the former.)

diff -urN amlfsp1/ --- amlfsp1/ 2005-03-09 15:22:08.000000000 -0500 +++ 2005-03-10 20:53:15.660873854 -0500 @@ -11,5 +11,5 @@ seq(1..3)->seq_map(\&supto)->seq_concat->enumerate; -#seq(1..3)->seq_concatmap(\&supto)->enumerate; +seq(1..3)->seq_concatmap(\&supto)->enumerate; diff -urN amlfsp1/ --- amlfsp1/ 2005-03-10 13:38:12.000000000 -0500 +++ 2005-03-10 20:56:21.166003398 -0500 @@ -101,7 +101,11 @@ } sub seq_series { - my $seqs = seq( @_ ); + seq( @_ )->seq_concat; +} + +sub seq_concat { + my $seqs = shift; my $seq; seqsub { my @val; @@ -166,19 +170,6 @@ wantarray ? @accum : $accum[0]; } -sub seq_concat { # FIXME: there's probably a slicker way of doing th +is... - my $seq = shift; - my @cache; - while (my @seqs = $seq->()) { - foreach my $s (@seqs) { - while (my @vals = $s->()) { - push @cache, @vals; - } - } - } - seq(@cache); -} - sub seq_concatmap { my ($seq, $fn) = @_; $seq->seq_map($fn)->seq_concat;

To apply the patch (on a Unix-esque system), save it into a file, "cd" into the directory containing, and then run this command: "patch -p1 < patchfile".


In reply to Re^2: A mini-language for sequences (part 1) by tmoertel
in thread A mini-language for sequences (part 1) by tmoertel

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2023-09-23 15:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found