Skip to content

Commit bc360dd

Browse files
committed
---
yaml --- r: 2727 b: refs/heads/master c: 1e9aef8 h: refs/heads/master i: 2725: 57cb21f 2723: 789b278 2719: 3569053 v: v3
1 parent ff8ad16 commit bc360dd

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d4f5f6993041e1c5a4d0de541bff14cc43784233
2+
refs/heads/master: 1e9aef828c057356badd464fcf7edb2f02d0b216

trunk/src/lib/list.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,49 @@ tag list[T] {
1111
}
1212

1313
fn foldl[T,U](&list[T] ls, &U u, fn(&T t, &U u) -> U f) -> U {
14-
alt(ls) {
15-
case (cons[T](?hd, ?tl)) {
16-
auto u_ = f(hd, u);
17-
// FIXME: should use 'be' here, not 'ret'. But parametric
18-
// tail calls currently don't work.
19-
ret foldl[T,U](*tl, u_, f);
20-
}
21-
case (nil[T]) {
22-
ret u;
14+
alt(ls) {
15+
case (cons[T](?hd, ?tl)) {
16+
auto u_ = f(hd, u);
17+
// FIXME: should use 'be' here, not 'ret'. But parametric
18+
// tail calls currently don't work.
19+
ret foldl[T,U](*tl, u_, f);
20+
}
21+
case (nil[T]) {
22+
ret u;
23+
}
2324
}
24-
}
2525

26-
fail; // TODO: remove me when exhaustiveness checking works
26+
fail; // TODO: remove me when exhaustiveness checking works
2727
}
2828

2929
fn find[T,U](&list[T] ls,
3030
(fn(&T) -> option::t[U]) f) -> option::t[U] {
31-
alt(ls) {
32-
case (cons[T](?hd, ?tl)) {
33-
alt (f(hd)) {
34-
case (none[U]) {
35-
// FIXME: should use 'be' here, not 'ret'. But parametric tail
36-
// calls currently don't work.
37-
ret find[T,U](*tl, f);
38-
}
39-
case (some[U](?res)) {
40-
ret some[U](res);
31+
alt(ls) {
32+
case (cons[T](?hd, ?tl)) {
33+
alt (f(hd)) {
34+
case (none[U]) {
35+
// FIXME: should use 'be' here, not 'ret'. But parametric
36+
// tail calls currently don't work.
37+
ret find[T,U](*tl, f);
38+
}
39+
case (some[U](?res)) {
40+
ret some[U](res);
41+
}
4142
}
4243
}
44+
case (nil[T]) {
45+
ret none[U];
46+
}
4347
}
44-
case (nil[T]) {
45-
ret none[U];
46-
}
47-
}
4848

49-
fail; // TODO: remove me when exhaustiveness checking works
49+
fail; // TODO: remove me when exhaustiveness checking works
5050
}
5151

5252
fn length[T](&list[T] ls) -> uint {
53-
fn count[T](&T t, &uint u) -> uint {
54-
ret u + 1u;
55-
}
56-
ret foldl[T,uint](ls, 0u, bind count[T](_, _));
53+
fn count[T](&T t, &uint u) -> uint {
54+
ret u + 1u;
55+
}
56+
ret foldl[T,uint](ls, 0u, bind count[T](_, _));
5757
}
5858

5959
fn cdr[T](&list[T] ls) -> list[T] {

0 commit comments

Comments
 (0)