两行代码实现全排列,erlang好强悍

-module(libmis).
-export([perms/1]).

perms([])   -> [[]];
perms(L)    -> [ [H|T] || H <- L, T <- perms(L--[H])].



Eshell V5.7.4  (abort with ^G)
1> c(libmis).
{ok,libmis}
2> libmis:perms("123").
["123","132","213","231","312","321"]
3>

你可能感兴趣的:(C++,c,erlang,C#)