Add a list append function, which I didn't end up using, but why not add it?
This commit is contained in:
parent
fc31aa7f85
commit
83cdb47a7c
1 changed files with 14 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue