[erlang-questions] working with sets
Fri Jan 4 13:11:37 CET 2008
On Fri, Jan 04, 2008 at 12:44:35PM +0100, Richard Carlsson wrote:
} If your elements are really integers within a limited range
They're string()'s in my case.
On Fri, Jan 04, 2008 at 12:42:04PM +0100, Ulf Wiger wrote:
} Just understanding the man page for sofs is a bit of a
} challenge, though. (:
It is indeed. It seems that if one were clever sofs would
provide a neat solution. In the mean time ...
I implemented my sets of sets over ordsets fairly simply.
My only dissatisfaction is that I don't have a lazy way
to find the first set in the set of sets which contains
an element. I'm all about lazy evaluation.
add_set(List, Set) when is_list(List) ->
case is_element_in_sets(List, Set) of
Elem = ordsets:from_list(List),
is_element_in_sets(, _) ->
is_element_in_sets([H|T], Set) when is_list(H) ->
F = fun(E, AccIn) ->
case ordsets:is_element(H, E) of
case ordsets:fold(F, false, Set) of
is_element_in_sets(_, _) ->
More information about the erlang-questions