tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,16 @@
declare
%% Given a set as a list, returns its powerset (again as a list)
fun {Powerset Set}
proc {Describe Root}
%% Describe sets by lower bound (nil) and upper bound (Set)
Root = {FS.var.bounds nil Set}
%% enumerate all possible sets
{FS.distribute naive [Root]}
end
AllSets = {SearchAll Describe}
in
%% convert to list representation
{Map AllSets FS.reflect.lowerBoundList}
end
in
{Inspect {Powerset [1 2 3 4]}}

View file

@ -0,0 +1,8 @@
fun {Powerset2 Set}
case Set of nil then [nil]
[] H|T thens
Acc = {Powerset2 T}
in
{Append Acc {Map Acc fun {$ A} H|A end}}
end
end