Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
This is actually a simpler problem, because the output for each iteration comes directly off of one of the input streams. One interesting property of that is that you can easily advance yourself in the output stream without generating the whole sequence.
use strict; use warnings; { my @streams = map [$_, 0], (2,3,5); sub limbic_sequence { my $first_after = shift; if (defined $first_after) { $_->[1] = int($first_after/$_->[0]) for @streams; } my ($lowest) = sort {$a <=> $b} map {($_->[1]+1) * $_->[0]} @s +treams; $_->[1]++ for grep {($_->[1]+1) * $_->[0] == $lowest} @streams +; $lowest; } } print join ', ', map limbic_sequence, 1..50; print "\n"; printf "First after 100000 is: %d\n", limbic_sequence(100000); print join ', ', map limbic_sequence, 1..50; print "\n"; __END__ #Output 2, 3, 4, 5, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 2 +7, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 50, 51 +, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68 First after 100000 is: 100002 100004, 100005, 100006, 100008, 100010, 100011, 100012, 100014, 100015 +, 100016, 100017, 100018, 100020, 100022, 100023, 100024, 100025, 100 +026, 100028, 100029, 100030, 100032, 100034, 100035, 100036, 100038, +100040, 100041, 100042, 100044, 100045, 100046, 100047, 100048, 10005 +0, 100052, 100053, 100054, 100055, 100056, 100058, 100059, 100060, 10 +0062, 100064, 100065, 100066, 100068, 100070, 100071

Caution: Contents may have been coded under pressure.

In reply to Re: Challenge: Another Infinite Lazy List by Roy Johnson
in thread Challenge: Another Infinite Lazy List by Limbic~Region

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (7)
    As of 2014-08-22 02:55 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (145 votes), past polls