Skip to content

Instantly share code, notes, and snippets.

@stathissideris
Last active August 29, 2015 13:57
Show Gist options
  • Save stathissideris/9349299 to your computer and use it in GitHub Desktop.
Save stathissideris/9349299 to your computer and use it in GitHub Desktop.
safe walk
(defn prewalkseq
"Like prewalk but only for seqs and uses zippers."
[f s]
(loop [z (zip/seq-zip s)]
(if (zip/end? z)
(zip/root z)
(recur (zip/next (zip/replace z (f (zip/node z))))))))
;;replace zip/seq-zip with zip/vector-zip for vectors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment