I think the "Powerset" function needs a correction: the H|{Powerset T}
expression won't give you what you want (unless it's a compact
expression representing the subset of the powerset that contains H).
Instead, you need to prepend H to every member of {Powerset T}, as
"PrependList" does below (using a difference list):
declare
fun {PrependList A L E}
case L
of nil then E
[] H|T then
(A|H)|{PrependList A T E}
end
end
fun {PowerSet L}
case L
of nil then [nil]
[] H|T then
P = {PowerSet T}
in
{PrependList H P P}
end
end
proc {ChoiceList L}
case L
of nil then skip
[] H|T then
choice H
[] {ChoiceList T}
end
end
end
{ ChoiceList {PowerSet [1 2 3]} }
-- Harmon
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Mark Engelberg
Sent: Sunday, March 05, 2006 4:00 PM
To: Peter Van Roy
Cc: [EMAIL PROTECTED]
Subject: Re: Choice and Power Sets
I do like the higher-order version. But here's a version that does it
all in one function:
fun {PowerSet L}
case L
of nil then nil
[] H|T then
choice H|{PowerSet T} [] {PowerSet T} end
end
end
--Mark
________________________________________________________________________
_________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users