copy-paste problems

This commit is contained in:
jungin.rhee
2023-08-18 16:07:30 +00:00
parent 3ef3cae0cd
commit b1f1f1a5fc
28 changed files with 3276 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
//! Generators
enum Yielded<T> {
Value(T),
Stop,
}
/// Generator
///
/// Reference:
/// - [Python generator](https://python-reference.readthedocs.io/en/latest/docs/generator/)
#[allow(missing_debug_implementations)]
pub struct Generator<T, S> {
state: S,
f: fn(&mut S) -> Yielded<T>,
}
impl<T, S> Iterator for Generator<T, S> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
todo!()
}
}
/// Returns a generator that yields fibonacci numbers.
pub fn fib_generator(first: usize, second: usize) -> Generator<usize, (usize, usize)> {
todo!()
}
/// Returns a generator that yields collatz numbers.
///
/// The generator stops when it reaches to 1.
pub fn collatz_conjecture(start: usize) -> Generator<usize, usize> {
todo!()
}