$|++;my($a,$b, $c)=(0,sub{$a+=2;$a-2?$ a%3?$|:$ a/3:$a}, sub{my($ a,$b,$c ,$d,$f) =(10,0, 0,1,@_) ;sub{my ($e,$g);until($b&&$d&&($e=int($a/$b)) ==int($c/$d)){$e=$f->();$g=$a;$a=$c;( $c*=$e)+=$g;$g=$b;$b=$d;($d*=$e)+=$g} $g=$a;$ a=$b;($ b*=-$e) +=$g;$g =$c;$c =$d;($d*= -$e)+=$ g;$e}});while(1){print$b-> ();$b=$c->($b)}#e
Thanks to Anonymous Subroutines for inspiration.
Update: Thanks also to tachyon for formatting tips (Re: e with continued fractions).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: e with c.f. and closures
by tachyon (Chancellor) on Aug 01, 2004 at 10:46 UTC |