-module perms -export perms perm_l perms perms perms L-- perm_l perm_l

1
2
3
4
5
6
7
8
9
-module(perms).
-export([perms/1,
perm_l/1]).
perms([]) -> [[]];
perms(L) -> [[H|T] || H <- L, T <- perms(L--[H])].
perm_l([])->[[]];
perm_l(L) -> [ [perms(H)|T] || H <-L, T <- perm_l(L--[H]) ].