Happy Pi Day!

| | Comments (0) | TrackBacks (0)

For those who put the month before the day (why?), today is 3/14: Pi day.

So happy Pi day! Have some pi:

let p d = take d(fix(\i y h->let(z,x)=fix(\f xs->case xs of{((n,d,c):y)->let{(z,k)=f
y;(q,r)=(c*10+k)`divMod`d}in((n,d,r):z,n*q);_->([],0)})y in case x of{9->i z(h++[9])
10->i z(map(\x->(x+1)`mod`10)h++[0]);_->h++i z[x]})((1,10,2):[(i,2*i+1,2)
|i<-[1..(10*d)`div`3]])[])in p 100

Feel free to change the "100" at the end to however much precision you need.

Categories

,

0 TrackBacks

Listed below are links to blogs that reference this entry: Happy Pi Day!.

TrackBack URL for this entry: http://andrew.bromage.org/mt/mt-tb.cgi/97

Leave a comment

About this Entry

This page contains a single entry by ajb published on March 14, 2008 4:26 PM.

Whose type system is it anyway? was the previous entry in this blog.

Beware, already! is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.1