function out = function perm(A)
% generates permutations of members of A
if length(A)==1
    out = {[A(1)]};
else
    n = length(A);
    out = perm(A(2:n));
    for j = 1:n
        out1=insert(out,j);
        out = [out,out1];
    end
end