Help:=proc() if nargs=0 then print(`Welcome to Catalan, a maple package written by`): print(`Joe Smith, smith at eden `): print(`Contains the procedures: LP, LP1 `): elif nargs=1 and args[1]=LP then print(`LP(n): Given an integer n , outputs the set of`): print(`ballot sequences with n 0's and n 1's`): print(`For example, try LP(5);`): elif nargs=1 and args[1]=LP1 then print(`LP1(n): Given an integer n , outputs the number of`): print(`ballot sequences with n 0's and n 1's`): print(`For example, try LP1(5);`): else print(`There is no Help for`, args): fi: end: LP:=proc(n) local i,se,se1,se2,i1,i2: option remember: if not type(n,integer) then ERROR(`Input must be an integer`): fi: if n<0 then RETURN({}): fi: if n=0 then RETURN({ [ ] }): fi: se:={}: for i from 0 to n-1 do se1:=LP(i): se2:=LP(n-i-1): se:=se union {seq(seq([0, op(se1[i1]), 1, op(se2[i2])], i2=1..nops(se2)),i1=1..nops(se1))}: od: se: end: #LP1(n): nops(LP(n)) directly LP1:=proc(n) local i: option remember: if not type(n,integer) then ERROR(`Input must be an integer`): fi: if n<0 then RETURN(0): fi: if n=0 then RETURN(1): fi: add(LP1(i)*LP1(n-i-1),i=0..n-1): end: