Last active
October 3, 2015 18:14
-
-
Save marcsolanadal/d177ab27ce82887a2c16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use 'clojure.walk) | |
(def my-vec [[1 2] [3 4]]) | |
(def simple-vec [1 2]) | |
; mapv approach | |
(defn rand-walk [x a] (+ x (* a (- (rand) (rand))))) | |
(defn rwalk->vec [v a] (mapv #(rand-walk % a) v)) | |
; working | |
(mapv #(rand-walk % 3) simple-vec) | |
(rwalk->vec [1 2] 3) | |
(mapv #(rwalk->vec % 3) my-vec) | |
; postwalk approach | |
(defn rand-walk | |
([x] (+ x (* 2 (- (rand) (rand))))) | |
([& more] (println more))) | |
; not working :( | |
(postwalk #(rwalk->vec % 3) my-vec) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment