export class Cons { constructor( public value: A, public next: Cons | undefined ) {} } export function concat(a: Cons, b: Cons): Cons { let list = new Cons(a.value, undefined); let prev = list; let cur = a; while ((cur = cur.next) !== undefined) { prev.next = new Cons(cur.value, undefined); prev = prev.next; } prev.next = b; return list; }