fun powerset [] = [ [] ] | powerset [x] = [ [x], [] ] | powerset (x :: y) = [ [x,y], [x], [y], [] ] | powerset (x :: y :: rest) = [ [x] ] @ powerset(x :: rest) @ powerset(y :: rest) ;