G
Size: a a a
G
AK
DS
DS
DS
DS
PK
DS
PK
DS
struct ConsStruct<A> { head: A, tail: List<A> }
enum List<A> {
Nil, Cons(Arc<ConsStruct<A>>)
}
impl<A> Clone for List<A> {
fn clone(&self) -> Self {
match self {
List::Nil => List::Nil,
Cons(arc) => Cons(arc.clone()),
}
}
}
impl <A> List<A> {
fn append(&self, head: A) -> Self {
let tail = self.clone();
Cons(Arc::new(ConsStruct { head, tail }))
}
}
DS
DS
DS
DS
DS
DS
DS
DS
EG
DS