我想找到Powerset
幂集 [1;2;3] = = [[]; [3];[2];[2; 3]; [1];[1; 3]; [1; 2]; [1; 2;3]]
let rec powerset = function
| [] -> []
| x::xs -> List.map (fun ys -> xs) xs::powerset (xs)
我的代码有问题,这就是我的输出现在的样子。
验证它:int list list list = [[[2; 3]; [2; 3]]; [[3]];[]]