Skip to content

Commit a8bb4af

Browse files
committed
---
yaml --- r: 11239 b: refs/heads/master c: 85175d6 h: refs/heads/master i: 11237: 86681c7 11235: 6345a92 11231: da3b12a v: v3
1 parent e95ec2e commit a8bb4af

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: c21db3bbc28c47e846783dedfe1eb1228f955f2b
2+
refs/heads/master: 85175d639f0b40062d2741f4918df48aee3ef758
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/iter.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ fn to_list<A:copy,IA:iterable<A>>(self: IA) -> [A] {
7777
foldl::<A,[A],IA>(self, [], {|r, a| r + [a]})
7878
}
7979

80+
// FIXME: This could be made more efficient with an riterable interface
81+
fn reverse<A:copy,IA:iterable<A>>(self: IA, blk: fn(A)) {
82+
vec::riter(to_list(self), blk)
83+
}
84+
8085
fn repeat(times: uint, blk: fn()) {
8186
let i = 0u;
8287
while i < times {
@@ -214,3 +219,8 @@ fn test_max() {
214219
fn test_max_empty() {
215220
max::<int, [int]>([]);
216221
}
222+
223+
#[test]
224+
fn test_reverse() {
225+
assert to_list(bind reverse([1, 2, 3], _)) == [3, 2, 1];
226+
}

0 commit comments

Comments
 (0)