This commit is contained in:
jungin.rhee
2023-08-21 11:52:05 +00:00
parent aa9f04b7d4
commit bba6cd9979
25 changed files with 32 additions and 307 deletions

View File

@@ -1,11 +1,17 @@
//! Generators
//!
//! HINT: Look at the `generator_grade.rs` file to see how the generator is used.
/// Yielded value. It can be either a value or a stop signal.
enum Yielded<T> {
Value(T),
Stop,
}
/// Generator
/// - kk
/// - You can call `next()` method to get the next value.
/// - The generator should stop when it yields `Yielded::Stop`.
///
/// Reference:
/// - [Python generator](https://python-reference.readthedocs.io/en/latest/docs/generator/)
@@ -24,13 +30,15 @@ impl<T, S> Iterator for Generator<T, S> {
}
/// Returns a generator that yields fibonacci numbers.
///
/// HINT: Consult <https://en.wikipedia.org/wiki/Fibonacci_sequence>
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.
/// HINT: Consult <https://en.wikipedia.org/wiki/Collatz_conjecture>
pub fn collatz_conjecture(start: usize) -> Generator<usize, usize> {
todo!()
}