[erlang-questions] working with sets
Vance Shipley
vances@REDACTED
Fri Jan 4 01:38:09 CET 2008
On Thu, Jan 03, 2008 at 03:06:08PM -0800, Michael McDaniel wrote:
} Seems like the sets module could help out.
I could use the sets module but I have to maintain an array myself.
1> Set1 = sets:from_list([1,2,3]),
1> Set2 = sets:from_list([4,5,6]),
1> Set3 = sets:from_list([7,8,9]),
1> Set = sets:from_list(Set1,Set2,Set3]).
2> sets:is_element(1, Set).
false
3> sets:is_element(Set1, Set).
true
4> sets:fold(fun(E, false) -> sets:is_element(9, E) end, false, Set).
true
5> sets:fold(fun(E, false) -> sets:is_element(10, E) end, false, Set).
false
So sure, I could manage a set of sets by rolling my own with the sets
module however I could do that with lists as well and it would be much
smaller than a set(). The sofs module sounds like it's what I should
be looking at however I can't see how it helps yet.
-Vance
I should really get that Okasaki book ...
More information about the erlang-questions
mailing list