-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca4aaa0
commit 0ae09e1
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pub type RangeIter ( | ||
head: Int, | ||
end: Int | ||
) | ||
|
||
impl Iter<Int> for RangeIter { | ||
fn next(self): Option<Int> { | ||
if self.head < self.end { | ||
let n = Some(self.head.copy()) | ||
self.head = self.head + 1 | ||
n | ||
} else { | ||
None() | ||
} | ||
} | ||
} | ||
|
||
pub fn range(start: Int, end: Int): RangeIter { | ||
RangeIter(head: start, end) | ||
} | ||
|
||
pub fn rangeClosed(start: Int, end: Int): RangeIter { | ||
RangeIter(head: start, end: end + 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