Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

↻ /prog/ Challenge [Vol. λfx.f x] ↻

Name: Anonymous 2011-02-13 12:14

THE CHALLENGE: Write a program that, given a number n, prints the expansion of (a+b)^n.

Example: 4a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4

HOWEVER: You must do the above in a language you do not have any experience with. Never programmed in Haskell before? Gather some documentation and go for it.

(Well, you're advised to do that. I can't possibly know whether or not you know a programming language.)

Name: Anonymous 2011-03-08 8:05

>>40
: combs ( n i -- nCi )
  1 1 d+ 1 tuck +do over i - * i / loop nip ;

: .power ( var exponent -- )
  dup 0 > if
    over emit
    dup 1 > if ." ^" dup 0 .r then
  then 2drop ;

: binomexp ( exponent -- )
  dup for
    dup i combs dup 1 > if dup 0 .r then drop
    'a i .power  'b over i - .power  ."  "
  next drop ;

Name: Anonymous 2011-03-08 8:20

>>39
U MENA HASKAL!

Name: Anonymous 2011-03-08 8:28

>>38
No garbage collection.
>CANCEL DOWNLOAD

Name: Anonymous 2011-03-08 8:35

<---- check em

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List