Skip to content

Instantly share code, notes, and snippets.

@travisbhartwell
Created January 23, 2009 11:59
Show Gist options
  • Save travisbhartwell/50987 to your computer and use it in GitHub Desktop.
Save travisbhartwell/50987 to your computer and use it in GitHub Desktop.
eDupItems' :: [Item] -> [Item] -> IdCountMap -> [Item]
deDupItems' (item:items) keptItems seenMap =
case delId of
Nothing -> deDupItems' items keptItems seenMap -- We didn't get an id, so drop it and move on
Just anId -> deDupItems' items itemsToKeep (Map.insert anId (count + 1) seenMap)
where
count = Map.findWithDefault defaultValue anId seenMap
itemsToKeep = if count > 0 then keptItems else keptItems ++ [item]
where
delId = getDeliciousUrlId item
deDupItems' [] keptItems seenMap = keptItems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment