Skip to content

Instantly share code, notes, and snippets.

@arsdragonfly
Created October 27, 2019 03:44
Show Gist options
  • Select an option

  • Save arsdragonfly/e3317804ff598b38911c2d769affe0c4 to your computer and use it in GitHub Desktop.

Select an option

Save arsdragonfly/e3317804ff598b38911c2d769affe0c4 to your computer and use it in GitHub Desktop.
let to where
findChanges :: Money -> [Money] -> Maybe [Money]
findChanges bill changes
| bill == 0 = Just changes
| bill < 0 = Nothing
| [] <- changes = Nothing
| (x : xs) <- changes = let result = findChanges (bill - x) xs in case result of Just c -> Just c
Nothing -> findChanges bill xs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment