tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
16
Task/Power-set/Oz/power-set-1.oz
Normal file
16
Task/Power-set/Oz/power-set-1.oz
Normal 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]}}
|
||||
8
Task/Power-set/Oz/power-set-2.oz
Normal file
8
Task/Power-set/Oz/power-set-2.oz
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue