Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created August 13, 2011 04:34
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 swannodette/1143483 to your computer and use it in GitHub Desktop.
Save swannodette/1143483 to your computer and use it in GitHub Desktop.
apat.clj
(defn addup
([xs] (addup xs 0 0))
([xs ones twos]
(match [xs ones twos]
[[] _ _] [ones twos]
[[1 & r] _ _] (recur r (inc ones) twos)
[[2 & r] _ _] (recur r ones (+ twos 2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment