Skip to content

Instantly share code, notes, and snippets.

@dminuoso

dminuoso/f.hs Secret

Created October 12, 2022 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dminuoso/f9a82bd74e4f568c08ff499d8a53e124 to your computer and use it in GitHub Desktop.
Save dminuoso/f9a82bd74e4f568c08ff499d8a53e124 to your computer and use it in GitHub Desktop.
lookupDel :: (Eq a) => a -> [(a,b)] -> Maybe (b, [(a, b)])
lookupDel _key [] = Nothing
lookupDel key as = go as emptyDList
where
go ((x,y):xys) ss
| key == x = Just (y, dlistApply ss xys)
| otherwise = go xys ((x,y) `dlistCons` ss)
go [] ss = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment