You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the title states. I have a function as follows:
mergeEquivalent:: (Orda) => (a->a->Bool) -> (a->a->a) -> ([a] -> [a])
mergeEquivalent (===)(+) xs =let-- https://github.com/quchen/articles/blob/master/2018-11-22_zipWith_const.md
indices =zipWithconst [0..] xs -- Because just [0..len] generates [0] when xs == []!
combis = pairs indices
update::IntSet.IntSet-> (Int, Int) ->EQ.EquivM__IntIntSet.IntSet
update =\s (i1, i2) ->do
eq <-EQ.equivalent i1 i2
if eq
thenpure s
elsedo
x1 <-EQ.classDesc i1
x2 <-EQ.classDesc i2
if (x1 === x2)
thendoEQ.equate i1 i2
pure$IntSet.delete i1 s
elsepure s
inEQ.runEquivM (xs !!) (+)$do
s <- foldM update (IntSet.fromList indices) combis
classes <- for (IntSet.toList s) EQ.classDesc
pure classes
But I have to manually keep track of the classes that exists. Is there a possibility that a function would be added that does this automatically? If I understand the implementation correctly, this should be possible in O(n)
An alternative would be to implement something like redundant :: v -> m Bool so that I can manually filter.
TL;DR:
I want an allElements :: m [v]
The text was updated successfully, but these errors were encountered:
Synthetica9
changed the title
Enumerate all distinct classes
Enumerate all distinct values
Jun 20, 2019
As the title states. I have a function as follows:
But I have to manually keep track of the classes that exists. Is there a possibility that a function would be added that does this automatically? If I understand the implementation correctly, this should be possible in O(n)
An alternative would be to implement something like
redundant :: v -> m Bool
so that I can manually filter.TL;DR:
I want an
allElements :: m [v]
The text was updated successfully, but these errors were encountered: