record list {value:integer, next:list}; { func cons (const v:integer, const n: list) -> list { return list{value := v, next := n} }; func map (const f:integer -> integer,const l:list) -> list { if l = nil then return nil else return cons(f(l.value),map(f,l.next)) }; func plus1 (const x:integer) -> integer { return x+1 }; func writelist (const l:list) { if l = nil then return else { write(l.value); writelist(l.next) } }; [* interactive tests *] const N := 5; loop { var l : list := nil; write ("enter ", N, " list elements "); var i := 0; for i := 0 to N-1 do { var x := 0; read (x); l := cons(x,l) }; write ("list is: "); writelist(l); write ("result is: "); const ll := map(plus1,l); writelist(ll); write ("original list is: "); writelist(l) } }