Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Using the subs whose definitions I posted in Re: Hamming Sequences and Lazy Lists, the following:

my $ones; $ones = ll_new(1, memoize(sub { $ones })); my $integers; $integers = ll_new(0, memoize(sub { ll_add($ones, $integers) })); sub multiples { my $n = shift; return ll_map( sub { $n * $_[0] }, $integers ); } sub challenge { return [] unless @_; my $x = shift; my $out; $out = merge( multiples($x), challenge(@_) ); return $out; } my @first_200 = take( 200, challenge(2, 3, 5) ); print "@first_200\n";
prints this out:
0 2 3 4 5 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26 27 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 69 70 72 74 75 76 78 80 81 82 84 85 86 87 88 90 92 93 94 95 96 +98 99 100 102 104 105 106 108 110 111 112 114 115 116 117 118 120 122 + 123 124 125 126 128 129 130 132 134 135 136 138 140 141 142 144 145 +146 147 148 150 152 153 154 155 156 158 159 160 162 164 165 166 168 1 +70 171 172 174 175 176 177 178 180 182 183 184 185 186 188 189 190 19 +2 194 195 196 198 200 201 202 204 205 206 207 208 210 212 213 214 215 + 216 218 219 220 222 224 225 226 228 230 231 232 234 235 236 237 238 +240 242 243 244 245 246 248 249 250 252 254 255 256 258 260 261 262 2 +64 265 266 267 268 270 272

the lowliest monk


In reply to Re: Challenge: Another Infinite Lazy List by tlm
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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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 lurking in the Monastery: (3)
    As of 2015-07-07 02:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (86 votes), past polls