Given the following sequence:
seq = ( (ab) ( (cd) a ) a ) (replace az seq) => ( (zb) ( (cd) z ) z )
How can I do this using lazy sequence and tail recursion?
It looks like you want to go through a data structure.
user=> (def s '((:a :b)((:c :d) :a) :a)) #'user/s user=> (use 'clojure.walk) nil user=> (prewalk #(if (= :a %1) :z %1) s) ((:z :b) ((:c :d) :z) :z)
EDIT: Or, if you really need to replace, just
user=> (prewalk-replace '{az} '((ab) ((cd) a))) ((zb) ((cd) z))