Personally I would use binary trees. One could also define a datatype like this 
one:

> datatype 'a nestl = A of 'a * 'a nestl | B of 'a nestl list * 'a nestl | NIL;
datatype 'a nestl = A of 'a * 'a nestl | B of 'a nestl list * 'a nestl | NIL
> A (3, B ([A(2,NIL)], A(4, A (5, NIL))));
val it = A (3, B ([A (2, NIL)], A (4, A (5, NIL)))): int nestl

That's not very elegant though.

Larry Paulson


> On 11 Oct 2016, at 15:28, David Topham <[email protected]> wrote:
> 
> I doubt if I am the first person to ask this question, but I have not seen an 
> "answer" in any of the ML books I have read yet...
> 
> Is there a way to represent a "set of sets" so that a function can process a 
> query such as  
> " is  [2] an element of [ 3 , [2], 4, 5]?"
> 
> I know we can easily do a query such as 
> " is 2 an element of [ 3 , 2, 4, 5]?"
> 
> I know the problem is that lists cannot have different types, but this is a 
> common, normal query in mathematics so someone must have figured out a way to 
> do it perhaps?
> 
> -Dave
> 
> _______________________________________________
> polyml mailing list
> [email protected]
> http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

_______________________________________________
polyml mailing list
[email protected]
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml

Reply via email to