Back

postwalk-replace (clj)

(source)

function

(postwalk-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 leaves of the tree first.

Examples

clojure
(ns clojure.test-clojure.clojure-walk
  (:require [clojure.walk :as w])
  (:use clojure.test))

(deftest t-postwalk-replace 
  (is (= (w/postwalk-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-postwalk-replace 
  (is (= (w/postwalk-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-postwalk-replace
  (is (= (w/postwalk-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-postwalk-replace 
  (is (= (w/postwalk-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-postwalk-replace 
  (is (= (w/postwalk-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 postwalk-replace-test
  (is-tc-e #(postwalk-replace {:a 1 :b 2} [:a :b])
           :requires [[clojure.walk :refer [postwalk-replace]]])
  (is-tc-err #(postwalk-replace 1 [:a :b])
             :requires [[clojure.walk :refer [postwalk-replace]]]))