Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change some names

  • Loading branch information...
commit e3c742963144e489aa25bcd7088157501077c7d4 1 parent 19625d0
@ztellman authored
Showing with 31 additions and 27 deletions.
  1. +2 −1  .gitignore
  2. +28 −25 src/sleight/walk.clj
  3. +1 −1  test/sleight/test/walk.clj
View
3  .gitignore
@@ -7,4 +7,5 @@
/checkouts
/.lein-deps-sum
target/**
-DS_Store
+DS_Store
+push
View
53 src/sleight/walk.clj
@@ -30,35 +30,38 @@
(and symbol? (resolve x))
x))
-(declare default-walk-handlers)
+(declare expr-handlers)
(defn walk-exprs
([x]
- (walk-exprs default-walk-handlers x))
+ (walk-exprs expr-handlers x))
([handlers x]
(let [handle-expr #(handle-expr handlers %1 %2 x)
- walk-exprs (partial walk-exprs handlers)]
- (cond
-
- (walkable? x)
- (doall (handle-expr (term-descriptor (first x)) #(map walk-exprs %)))
-
- (map-entry? x)
- (handle-expr #'sleight.walk/map-entry #(clojure.lang.MapEntry.
- (walk-exprs (key %))
- (walk-exprs (val %))))
-
- (vector? x)
- (handle-expr #'clojure.core/vector #(vector (map walk-exprs %)))
-
- (map? x)
- (handle-expr #'clojure.core/hash-map #(into {} (map walk-exprs %)))
-
- (set? x)
- (handle-expr #'clojure.core/hash-set #(set (map walk-exprs %)))
-
- :else
- x))))
+ walk-exprs (partial walk-exprs handlers)
+ x* (cond
+
+ (walkable? x)
+ (doall (handle-expr (term-descriptor (first x)) #(map walk-exprs %)))
+
+ (map-entry? x)
+ (handle-expr #'sleight.walk/map-entry #(clojure.lang.MapEntry.
+ (walk-exprs (key %))
+ (walk-exprs (val %))))
+
+ (vector? x)
+ (handle-expr #'clojure.core/vector #(vector (map walk-exprs %)))
+
+ (map? x)
+ (handle-expr #'clojure.core/hash-map #(into {} (map walk-exprs %)))
+
+ (set? x)
+ (handle-expr #'clojure.core/hash-set #(set (map walk-exprs %)))
+
+ :else
+ x)]
+ (if (instance? clojure.lang.IMeta x*)
+ (with-meta x* (merge (meta x) (meta x*)))
+ x*))))
;;;
@@ -89,7 +92,7 @@
(let-bindings-handler handlers (second x))
(map (partial walk-exprs handlers) (drop 2 x))))
-(def default-walk-handlers
+(def expr-handlers
{#'defn fn-handler
#'fn fn-handler
'fn* fn-handler
View
2  test/sleight/test/walk.clj
@@ -31,7 +31,7 @@
(defn eval* [x]
(eval
(walk-exprs
- (merge default-walk-handlers {#'+ increment-handler})
+ (merge expr-handlers {#'+ increment-handler})
x)))
(deftest test-walk-exprs
Please sign in to comment.
Something went wrong with that request. Please try again.