Back
prewalk-replace (clj)
(source)function
(prewalk-replace smap form)
Recursively transforms form by replacing keys in smap with their
values. Like clojure/replace but works on any data structure. Does
replacement at the root of the tree first.
Examples
clojure
(ns clojure.test-clojure.clojure-walk
(:require [clojure.walk :as w])
(:use clojure.test))
(deftest t-prewalk-replace
(is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
[:b {:b :b} (list 3 :c :b)])))
clojure/clojure
(ns clojure.test-clojure.clojure-walk
(:require [clojure.walk :as w])
(:use clojure.test))
(deftest t-prewalk-replace
(is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
[:b {:b :b} (list 3 :c :b)])))
clojure/clojurescript
(ns cljs.walk-test
(:require [cljs.test :refer-macros [deftest testing is]]
[clojure.walk :as w]))
(deftest t-prewalk-replace
(is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
[:b {:b :b} (list 3 :c :b)])))
arcadia-unity/Arcadia
(ns clojure.test-clojure.clojure-walk
(:require [clojure.walk :as w])
(:use clojure.test))
(deftest t-prewalk-replace
(is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
[:b {:b :b} (list 3 :c :b)])))
clojure/clojure-clr
(ns clojure.test-clojure.clojure-walk
(:require [clojure.walk :as w])
(:use clojure.test))
(deftest t-prewalk-replace
(is (= (w/prewalk-replace {:a :b} [:a {:a :a} (list 3 :c :a)])
[:b {:b :b} (list 3 :c :b)])))
clojure/core.typed
(deftest keywordize-keys-test
(is-tc-e #(keywordize-keys {"a" 1 "b" 2})
:requires [[clojure.walk :refer [keywordize-keys]]]))
(deftest prewalk-replace-test
(is-tc-e #(prewalk-replace {:a 1 :b 2} [:a :b])
:requires [[clojure.walk :refer [prewalk-replace]]])
(is-tc-err #(prewalk-replace 1 [:a :b])
:requires [[clojure.walk :refer [prewalk-replace]]]))