Skip to content

Commit 83cdb47

Browse files
committed
Add a list append function, which I didn't end up using, but why not add it?
1 parent fc31aa7 commit 83cdb47

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/lib/list.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ fn car[T](&list[T] ls) -> T {
7070
}
7171
}
7272

73+
74+
fn append[T](&list[T] l, &list[T] m) -> list[T] {
75+
alt (l) {
76+
case (nil[T]) {
77+
ret m;
78+
}
79+
case (cons[T](?x, ?xs)) {
80+
let list[T] rest = append[T](*xs, m);
81+
ret cons[T](x, @rest);
82+
}
83+
}
84+
}
85+
86+
7387
// Local Variables:
7488
// mode: rust;
7589
// fill-column: 78;

0 commit comments

Comments
 (0)