type List LEOF | (LCons( x , List[] )); zero List LEOF; cons := λ(: hd x)(: tl List). (: ( (set tl (LCons( hd (close tl) ))) tl ) List); head := λ(: l List). (: ( (match l ( () ( LEOF (fail 'List::head\sis\sfallible\n_s) ) ( _ () ) )) (.2(as l List+Tag)) ) x); + := λ(: hd List)(: tl List). (: ( (set hd (reverse hd)) (while (non-zero hd) (match hd ( () ( (LCons( hdhd tlhd )) ( (set tl (cons( hdhd tl ))) (set hd tlhd) )) ))) tl ) List); .length := λ(: list List). (: ( (let l 0_u64) (while (non-zero list) ( (match list ( () ( (LCons( _ tl )) (set list tl) ) )) (set l (+( l 1_u64 ))) )) l ) U64); reverse := λ(: l List). (: ( (let r (: LEOF List)) (while (non-zero l) (match l ( () ( (LCons( v rst )) ( (set r (LCons( v (close r) ))) (set l rst) )) ))) r ) List); print := λ(: l List). (: ( (print '[_s) (let some False_u8) (while (non-zero l) (match l ( () ( (LCons( v rst )) ( (if (==( some True_u8 )) (print ',_s) ()) (print v) (set some True_u8) (set l rst) )) ))) (print ']_s) ) Nil); .nth := λ(: tt List)(: i U64)(: default x). (: ( (while (>( i 0_u64 )) ( (match tt ( () ( (LCons( _ rst )) (set tt rst) ) ( _ () ) )) (set i (-( i 1_u64 ))) )) (match tt ( () ( (LCons( d _ )) (set default d) ) ( _ () ) )) default ) Type);