1
Fork 0

stdlib: Do tail calls in std::list. Remove FIXMEs

This commit is contained in:
Brian Anderson 2011-05-22 00:46:50 -04:00
parent bac68e4af3
commit f6beec6c43

View file

@ -25,15 +25,12 @@ fn foldl[T,U](&list[T] ls, &U u, fn(&T t, &U u) -> U f) -> U {
alt(ls) { alt(ls) {
case (cons[T](?hd, ?tl)) { case (cons[T](?hd, ?tl)) {
auto u_ = f(hd, u); auto u_ = f(hd, u);
// FIXME: should use 'be' here, not 'ret'. But parametric be foldl[T,U](*tl, u_, f);
// tail calls currently don't work.
ret foldl[T,U](*tl, u_, f);
} }
case (nil[T]) { case (nil[T]) {
ret u; ret u;
} }
} }
fail; // TODO: remove me when exhaustiveness checking works fail; // TODO: remove me when exhaustiveness checking works
} }
@ -43,9 +40,7 @@ fn find[T,U](&list[T] ls,
case (cons[T](?hd, ?tl)) { case (cons[T](?hd, ?tl)) {
alt (f(hd)) { alt (f(hd)) {
case (none[U]) { case (none[U]) {
// FIXME: should use 'be' here, not 'ret'. But parametric be find[T,U](*tl, f);
// tail calls currently don't work.
ret find[T,U](*tl, f);
} }
case (some[U](?res)) { case (some[U](?res)) {
ret some[U](res); ret some[U](res);