Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Tsk, tsk, Haskell is such a verbose language. :) In Perl 6 it' just:
[\~] 1 xx *
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". That even works today in pugs if you replace the * with, say, 10:
pugs> .say for [\~] 1 xx 10 1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111
Or using the new, spiffily readable ... infix, it's even shorter:
That just extends the list on the left by concatenating a 1 onto the previous last value of the list. But nobody has implemented that one yet, since we only invented it on Sunday... :)

The cool thing about it is that (if you're not golfing it) you can write however much of the list you like as an example for the human reader, and give the parameter a better name:

1,11,111,1111 ... {$^previous ~ 1}

Update: nowadays (2010/04/03) the closure goes on the left, so we'd write those more like:

1,*~1...* 1, 11, 111, 1111, {$^previous ~ 1} ... *

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

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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others contemplating the Monastery: (3)
    As of 2018-05-26 06:58 GMT
    Find Nodes?
      Voting Booth?