Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created September 12, 2011 03:22
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 amalloy/1210514 to your computer and use it in GitHub Desktop.
Save amalloy/1210514 to your computer and use it in GitHub Desktop.
(let [in "68+249*201-87"
pred (set "+*-/")]
(second
(last
(take-while #(< (first %) 2)
(reductions (fn [[count acc] item]
[(if (pred item)
(inc count)
count)
(conj acc item)])
[0 []]
in)))))
[\6 \8 \+ \2 \4 \9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment