Skip to content

Instantly share code, notes, and snippets.

@travisbhartwell
Created February 18, 2009 01:57
Show Gist options
  • Select an option

  • Save travisbhartwell/66138 to your computer and use it in GitHub Desktop.

Select an option

Save travisbhartwell/66138 to your computer and use it in GitHub Desktop.
deDupItems' :: [Item] -> [Item] -> IdCountMap -> ([Item], IdCountMap)
deDupItems' (item:items) keptItems seenMap =
case getDeliciousUrlId item 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]
deDupItems' [] keptItems seenMap = (keptItems, seenMap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment