I have a problem where i have to manipulate a list of a list of floats. [[Float]]. these list of floats are of length 4. I want to remove duplicates where the first 3 elements are tested, but ignore the 4th one. This is the last part of a multi part problem and i have been banging my head on a wall for a while figuring out how to use this. I cant find any helpful information.
fixDuplicates :: [[Float]] -> [[Float]]
fixDuplcates [[]] = [[]]
fixDuplicates x = nubBy ?
nubBy
takes a function to use for comparing elements for equality. Your definition of equality is that two lists are equal if their first three elements match. A straightforward implementation of this is:
fixDuplicates xs = nubBy firstThreeMatch xs
where firstThreeMatch ys zs = take 3 ys == take 3 zs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With