Skip to content

Instantly share code, notes, and snippets.

@m-alvarez
Created April 23, 2015 02:42
Show Gist options
  • Save m-alvarez/9b81383e15633c542582 to your computer and use it in GitHub Desktop.
Save m-alvarez/9b81383e15633c542582 to your computer and use it in GitHub Desktop.
Checking for balanced parentheses
validParentheses = (== 1) . foldl (flip ($)) 1 . map (\case { '(' -> (* 2); ')' -> (`div` 2) })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment