Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

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

This horribly inefficient brute-force conversion seems like it's getting close, but needs work.

#! perl -slw use strict; sub merge { return unless @_ == 2; return @{ $_[1] } unless @{ $_[0] }; return @{ $_[0] } unless @{ $_[1] }; my( $x, $y ) = ( $_[0][0], $_[1][0] ); return shift @{ $_[0] }, merge( @_ ) if $x < $y; return shift @{ $_[1] }, merge( @_ ) if $x > $y; shift @{ $_[0] }; return shift @{ $_[1] }, merge( @_ ); } my @out; sub genHam { return unless @_; my( $x, @xs ) = @_; return @out = merge [ 1, map{ $_*$x } @out ], [ genHam( @xs ) ]; } print join'|',genHam 2, 3, 5 for 1..5; __END__ [ 8:26:05.53] P:\test>440284 1 1|2|3|5 1|2|3|4|5|6|9|10|15|25 1|2|3|4|5|6|8|9|10|12|15|18|20|25|27|30|45|50|75|125 1|2|3|4|5|6|8|9|10|12|15|16|18|20|24|25|27|30|36|40|45|50|54|60|75|81| +90|100|125|135|150|225|250|375|625

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

In reply to Re: Hamming Sequences and Lazy Lists by BrowserUk
in thread Hamming Sequences and Lazy Lists by tall_man

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (5)
    As of 2015-11-29 09:24 GMT
    Find Nodes?
      Voting Booth?

      What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

      Results (750 votes), past polls