stdlib: Do tail calls in std::list. Remove FIXMEs
This commit is contained in:
parent
bac68e4af3
commit
f6beec6c43
1 changed files with 2 additions and 7 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue