Permalink
Browse files

Pulling out map manipulation fns into thneed

  • Loading branch information...
1 parent fd4ab54 commit 566280b3e58ceb78abc7a3e3e3ec86fd1383e84b @fogus committed Mar 30, 2012
Showing with 8 additions and 30 deletions.
  1. +4 −2 project.clj
  2. +4 −3 src/trammel/core.clj
  3. +0 −25 src/trammel/utils.clj
View
@@ -1,12 +1,14 @@
(defproject trammel "0.7.0-SNAPSHOT"
:description "A library providing contracts programming for Clojure."
- :dependencies [[org.clojure/clojure "1.3.0"]]
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [thneed "1.0.0-SNAPSHOT"]]
:dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
[jline "0.9.94"]
[swank-clojure "1.4.0"]
[lein-marginalia "0.7.0"]
[lein-multi "1.1.0"]]
- :multi-deps {"1.2" [[org.clojure/clojure "1.2.0"]]
+ :multi-deps {:all [[thneed "1.0.0-SNAPSHOT"]]
+ "1.2" [[org.clojure/clojure "1.2.0"]]
"1.3" [[org.clojure/clojure "1.3.0"]]
"1.4" [[org.clojure/clojure "1.4.0-beta1"]]})
@@ -15,7 +15,8 @@
"The core contracts programming functions and macros for Trammel."
(:use [trammel.funcify :only (funcify)])
(:use trammel.factors)
- (:use trammel.utils))
+ (:use trammel.utils)
+ (:require [fogus.thneed.utils :as fogus]))
;; HOF support
@@ -64,8 +65,8 @@
(let [hocs (tag-hocs args cnstr)]
[args
(->> (build-pre-post-map cnstr)
- (manip-map (partial funcify '[%]) [:post])
- (manip-map (partial funcify args) [:pre]))]))
+ (fogus/manip-map (partial funcify '[%]) [:post])
+ (fogus/manip-map (partial funcify args) [:pre]))]))
(comment
(let [hoc (_ [n] even? number? => number?)]
View
@@ -16,28 +16,3 @@
"{:pre [pre-conditions]}"
"for record type " name)))
-(defn ^:private keys-apply
- "Takes a function, a set of keys, and a map and applies the function to the map on the given keys.
- A new map of the results of the function applied to the keyed entries is returned.
- "
- [f ks m]
- {:pre [(or (fn? f) (keyword? f) (symbol? f))
- (except (coll? ks) (map? ks))
- (map? m)]
- :post [(map? %)]}
- (let [only (select-keys m ks)]
- (zipmap (keys only)
- (map f (vals only)))))
-
-(defn manip-map
- "Takes a function, a set of keys, and a map and applies the function to the map on the given keys.
- A modified version of the original map is returned with the results of the function applied to each
- keyed entry.
- "
- [f ks m]
- {:pre [(or (fn? f) (keyword? f) (symbol? f))
- (except (coll? ks) (map? ks))
- (map? m)]
- :post [(map? %)
- (= (keys %) (keys m))]}
- (conj m (keys-apply f ks m)))

0 comments on commit 566280b

Please sign in to comment.