Created
February 11, 2013 17:54
-
-
Save alexandreaquiles/4756153 to your computer and use it in GitHub Desktop.
Lazy Fibonacci implementation using the Totally Lazy library.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import static com.googlecode.totallylazy.Callables.first; | |
| import static com.googlecode.totallylazy.Computation.computation; | |
| import static com.googlecode.totallylazy.Pair.reduceLeftShift; | |
| import com.googlecode.totallylazy.Pair; | |
| import com.googlecode.totallylazy.Sequence; | |
| import com.googlecode.totallylazy.numbers.Sum; | |
| public class TotallyLazyFibonacci { | |
| public static Sequence<Number> fibonacciSequence = | |
| computation(Pair.<Number, Number>pair(0, 1), reduceLeftShift(new Sum())).map(first(Number.class)); | |
| public static void main(String[] args) { | |
| System.out.println(fibonacciSequence.take(25).toList()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment