This file contains 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
use std::iter; | |
fn main() { | |
println!("{:?}", fibs_iter().skip(42).next().unwrap()); | |
println!("{}", fibs_recursive(42)); | |
} | |
fn fibs_iter() -> impl Iterator<Item = u128> { | |
let mut a = 0; | |
let mut b = 1; |
This file contains 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
trait Monad<A> { | |
type M<X>: Monad<X>; | |
fn unit(a: A) -> Self::M<A>; | |
fn bind<B, F>(self, f: F) -> Self::M<B> | |
where | |
F: FnMut(A) -> Self::M<B>; | |
} |