Hi everyone, 

I was trying to understand the behaviour of the Set/MkRedBlackSet couple. 
I have a list of strings that I'd like to store in a Set. 
Now, if I understand correctly the right way should be:

import structure MkRedBlackSet  from "x-alice:/lib/data/MkRedBlackSet"
structure Set = MkRedBlackSet String
val set = Set.fromList mylist

The problem is that my list may contain duplicate words, and that would
cause an exception to be raised. 
To avoid the excpetion I came up with this:

foldl (fn (item, set) => Set.insert (set, item)) (Set.empty) ws

and it seems to work, so I am happy :) 

But it seems to me that inserting a list that may contain duplicates into
a set is quite a common operation, would it make sense to provide 
this functionality as builtin, or is there some underlying rationale that I
am missing?

Thanks in advance.



-- 
goto 10: http://www.goto10.it
blog it: http://riffraff.blogsome.com
blog en: http://www.riffraff.info

_______________________________________________
alice-users mailing list
[email protected]
http://www.ps.uni-sb.de/mailman/listinfo/alice-users

Reply via email to