// make list cell[1000]; freecell; // access functions head(a){ return cell[a];} tail(a){ return cell[a+1];} sethead(a,i){ cell[a] = i;} settail(a,i){ cell[a+1] = i;} newnode(i){ // get a new node, with i p = freecell; freecell = freecell + 2; if( freecell > 10000 ) print("no more cell"); sethead(p,i); settail(p,0); return p; } // link node a to list m insert(m,a){ settail(a,tail(m)); settail(m,a); } // print item in list recursively prlist2(m){ if( m != 0 ){ print(head(m)," "); prlist2(tail(m)); } } // main print list, skip header node prlist(m){ prlist2(tail(m)); } main(){ h = newnode(0); // make header insert(h,newnode(1)); insert(h,newnode(2)); insert(h,newnode(3)); prlist(h); }