-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
50 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
(ns aero.impl.walk) | ||
|
||
(defn- walk | ||
[inner outer form] | ||
(let [x (cond | ||
(list? form) (outer (apply list (map inner form))) | ||
#?@(:cljs [(map-entry? form) (outer (MapEntry. (inner (key form)) (inner (val form)) nil))] | ||
:clj [(instance? clojure.lang.IMapEntry form) (outer (vec (map inner form)))]) | ||
(seq? form) (outer (doall (map inner form))) | ||
#?(:cljs (record? form) | ||
:clj (instance? clojure.lang.IRecord form)) | ||
(outer (reduce (fn [r x] (conj r (inner x))) form form)) | ||
(coll? form) (outer (into (empty form) (map inner form))) | ||
:else (outer form))] | ||
(if #?(:cljs (implements? IWithMeta x) | ||
:clj (instance? clojure.lang.IObj x)) | ||
(with-meta x (merge (meta form) (meta x))) | ||
x))) | ||
|
||
(defn postwalk | ||
[f form] | ||
(walk (partial postwalk f) f form)) |
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