Help3:=proc(): print(`AP(L,a), CAT(L1,L2), REV(L), HP(n) , NEXT(w), PREV(w) `):end: CAT:=proc(L1,L2): [op(L1),op(L2)]:end: #AP(L,a): Appending a to every member of the list L AP:=proc(L,a) local i: [seq([op(L[i]),a],i=1..nops(L))]: end: #REV(L): the reverse of L REV:=proc(L) local i:[seq(L[-i],i=1..nops(L))]:end: HP:=proc(n) local L: option remember: if n=0 then RETURN([[]]): else L:=HP(n-1): CAT(AP(L,0),AP(REV(L),1)): fi: end: NEXT:=proc(w) local n,w1: option remember: n:=nops(w): if n=0 then RETURN(FAIL): fi: w1:=[op(1..n-1,w)]: if w[n]=0 then if NEXT(w1)<>FAIL then RETURN([op(NEXT(w1)),0]): else RETURN([op(w1),1]): fi: else if PREV(w1)<>FAIL then RETURN([op(PREV(w1)),1]): else RETURN(FAIL): fi: fi: end: PREV:=proc(w) local n,w1: option remember: n:=nops(w): if n=0 then RETURN(FAIL): fi: w1:=[op(1..n-1,w)]: if w[n]=0 then if PREV(w1)<>FAIL then RETURN([op(PREV(w1)),0]): else RETURN(FAIL): fi: else if NEXT(w1)<>FAIL then RETURN([op(NEXT(w1)),1]): else RETURN([op(w1),0]): fi: fi: end: