Skip to content

Would this be better for rev step by 2 #12

@ghmorrison

Description

@ghmorrison

I am still just learning Rust but I liked the second one better.

Section: Combining Iterator Adaptors
Sub-section: Complex Chains

for i in (0..=10).rev().filter(|x| x % 2 == 0) { print!("{} ", i); }

for i in (0..=10).rev().step_by(2) { print!("{} ", i); }

Again for:

`let r = (1..20)
.filter(|&x| x % 5 == 0)
.chain((6..9).rev());

for i in r {
print!("{} ", i);
}`

`let r = (5..20)
.step_by(5)
.chain((6..9).rev());

for i in r {
print!("{} ", i);
}`

Thanks for the tutorial,
George

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions