Skip to content

Instantly share code, notes, and snippets.

@ochronus
Created April 2, 2016 10:12
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 ochronus/9f03a19c92c2b8d43c9ad9aae9c97d5a to your computer and use it in GitHub Desktop.
Save ochronus/9f03a19c92c2b8d43c9ad9aae9c97d5a to your computer and use it in GitHub Desktop.
find-bracket (fn [opening-bracket closing-bracket instruction-pointer direction]
(loop [i (direction instruction-pointer) opened 0]
(condp = (nth program-code i)
opening-bracket (recur (direction i) (inc opened))
closing-bracket (if (zero? opened) i (recur (direction i) (dec opened)))
(recur (direction i) opened))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment