[algorithm] Algorithm to generate all possible permutations of a list?

Bourne shell solution - in a total of four lines (without test for no param case):

test $# -eq 1 && echo "$1" && exit
for i in $*; do
  $0 `echo "$*" | sed -e "s/$i//"` | sed -e "s/^/$i /"
done