1 person following this project (follow)

Project Description
A lazy evaluation library for mathematics. Keep code from being evaluated until it is needed. I borrow this idea from other functional languages. Supports infinite sequences, it uses caching for this so algorithms that randomly access complex infinite sequences perform well.

LazyNumber x = new LazyNumber( Math.PI	);
LazyNumber y = new LazyNumber( Math.E	);
x.LazilyDo( (l)=> l / 2 );	
x.LazilyDo( (l)=> (l * 215) * y.LazilyDo( (m)=> m / 5 ).Result );
x.LazilyDo( (l)=> l + Math.Sin(2) );

LazySequence<double> fib = null; //fib must be separately initialized because the lambdas below reference fib var
fib = new LazySequence<double>( new double[] {0, 1, 1}, (i)=>( fib[i-1] + fib[i-2] ) );
for( int i = 0; i < 250; i++ )
    Console.WriteLine( fib[i] );			

Last edited May 15 2009 at 4:02 PM by CoryDambach, version 4