Add a list append function, which I didn't end up using, but why not add it?

This commit is contained in:
Tim Chevalier 2011-05-26 19:05:23 -07:00
parent fc31aa7f85
commit 83cdb47a7c

View File

@ -70,6 +70,20 @@ fn car[T](&list[T] ls) -> T {
}
}
fn append[T](&list[T] l, &list[T] m) -> list[T] {
alt (l) {
case (nil[T]) {
ret m;
}
case (cons[T](?x, ?xs)) {
let list[T] rest = append[T](*xs, m);
ret cons[T](x, @rest);
}
}
}
// Local Variables:
// mode: rust;
// fill-column: 78;