I liked a lot your versions , now it's time for me to write my own in Perl6 , so here it goes:

sub bc($n,$k){[*]map ->$x, $y{$x/$y},(($k+1..$n)Z(1..$n-$k));} (this version is described)
sub bc($n,$k){[*]map ->$x, $y{$x/$y},(($n-$k+1..$n)Z(1..$k));} (the same thing,if you simplify (n-k)! instead of k!)

I beat the initial one(the "__" one) by 2 characters (mine is 62 characters). It's still compact code but more readable in the sense that one can identify that you're first zipping together two arrays namely the intervals $k+1 -> $n and 1 -> $n-$k which happens if you simplify the k! with the denumerator in the definition of the combinations , after that we're iterating on both intervals at the same time and we're making fractions with their elements , and after that we reduce the fractions by multiplying all of them together using this reduce meta-operator. I find that Perl6 leads to natural code.

Thanks go to moritz_,TimToady,Limbic-Region,jnthn on #perl6 , irc.freenode.net :)


In reply to Re: binomial coefficient by spx2
in thread binomial coefficient by Anonymous Monk

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!
  • 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, details, 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, summary, 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.