$touch mth.erl
$vi mth.erl
<INSRT>
-module(mth).
-export([perms/1]).
perms([]) -> [[]];
perms(L) -> [[H|T] || H <- L, T <- perms(L--[H])].
<ESC>:wq
$erl
Erlang (BEAM) emulator version 5.6.5 [source] [64-bit] [smp:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.6.5 (abort with ^G)
1> c(mth).
{ok,mth}
2> mth:perms("Pyth").
["Pyth","Pyht","Ptyh","Pthy","Phyt","Phty","yPth","yPht",
"ytPh","ythP","yhPt","yhtP","tPyh","tPhy","tyPh","tyhP",
"thPy","thyP","hPyt","hPty","hyPt","hytP","htPy","htyP"]
3> mth:perms("Pytha").
["Pytha","Pytah","Pyhta","Pyhat","Pyath","Pyaht","Ptyha",
"Ptyah","Pthya","Pthay","Ptayh","Ptahy","Phyta","Phyat",
"Phtya","Phtay","Phayt","Phaty","Payth","Payht","Patyh",
"Pathy","Pahyt","Pahty","yPtha","yPtah","yPhta","yPhat",
[...]|...]
4>
[...]|...] <------------ ????