-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add intersections
function
#41
Comments
The only problem with this is that the intersections of an empty list of sets really ought to be a set containing every inhabitant of |
We can start with a For example, I tried rewriting this Venn diagram code with non-empty The simplest fix I found for the above is to simply recreate the desired library function locally: my_intersections :: forall f a. Foldable f => Ord a => f (Set a) -> Set a
my_intersections sets = case List.fromFoldable sets of
Nil -> Set.empty
(x : xs) -> intersections $ NEL.cons' x xs Also, I was hoping that this would be a valid way to write the intersections :: forall f a. Foldable1 f => Ord a => f (Set a) -> Set a
intersections = foldl1 intersection But it will not compile because |
Foldable1 has a foldl1 method since purescript/purescript-foldable-traversable#121. |
The reason I don’t want to have an intersections function which says that the intersection of an empty list of sets is empty is that properties like |
I have to admit I haven’t been able to work out what your vennCell is trying to do. |
That sounds good for now. Can always add it to the library later if there's more demand or evidence that it simplifies things.
Thanks. I've been relying too much on Pursuit / Starsuit to answer these questions.
It finds the contents of a "cell" in a venn diagram if provided with which sets to consider ("keep") and exclude ("toss"). For example, given these labeled sets:
which represents this diagram: If Full try-purescript output for that basic input is:
The results are more interesting if each cell contains more than one element, such as in purescript/purescript-lists#183 |
We have
union
,unions
, andintersection
, but nointersections
.I've been using this locally:
PR with tests and docs on the todo list.
The text was updated successfully, but these errors were encountered: