mirror of
https://github.com/kmc7468/cs220.git
synced 2025-12-16 06:58:45 +00:00
polish
This commit is contained in:
@@ -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!()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user