Commits

Meikel Brandmeyer committed c531805

Cleanup docs and added namespace docstring

Comments (0)

Files changed (1)

src/de/kotka/lazymap.clj

 ; THE SOFTWARE.
 
 (clojure.core/ns de.kotka.lazymap
+  "Lazymap is to maps what lazy-seq is to lists. It allows to store values
+  with evaluating them. This is only done in case the value is really accessed.
+  Lazymap works with any map type (hash-map, sorted-map, struct-map) and may
+  be used as a drop-in replacement everywhere where a normal map type may be
+  used.
+
+  Available macros:
+  lazy-hash-map, lazy-sorted-map, lazy-struct-map, lazy-struct, lazy-assoc
+  and their * counterpart functions."
   (:import
      (de.kotka.lazymap LazyMap)))
 
   (mapcat (fn [[k v]] [k `(delay ~v)]) (partition 2 kvs)))
 
 (defn lazy-assoc*
-  "<lazy-assoc*> is like <lazy-assoc> but a function and takes values as delays
+  "lazy-assoc* is like lazy-assoc but a function and takes values as delays
   instead of expanding into a delay of val."
   [m & kvs]
   (assert (even? (count kvs)))
   (reduce (fn [m [k v]] (.lazyAssoc m k v)) m (partition 2 kvs)))
 
 (defmacro lazy-assoc
-  "<lazy-assoc> associates new values to the given keys in the given lazy map.
+  "lazy-assoc associates new values to the given keys in the given lazy map.
   The values are not evaluated, before their first retrieval. They are
   evaluated at most once."
   [m & kvs]
   `(lazy-assoc* ~m ~@(quote-values kvs)))
 
 (defn lazy-hash-map*
-  "<lazy-hash-map*> is the same as <lazy-hash-map> except that its a function
+  "lazy-hash-map* is the same as lazy-hash-map except that its a function
   and it takes a seq of keys-delayed-value pairs."
   [& kvs]
   (LazyMap. (apply hash-map kvs)))
 
 (defmacro lazy-hash-map
-  "<lazy-hash-map> creates a map. The values are not evaluated before their
+  "lazy-hash-map creates a map. The values are not evaluated before their
   first retrieval. Each value is evaluated at most once. The underlying map
   is a hash map."
   [& kvs]
   `(lazy-hash-map* ~@(quote-values kvs)))
 
 (defn lazy-sorted-map*
-  "<lazy-sorted-map*> is the same as <lazy-sorted-map> except that its a
+  "lazy-sorted-map* is the same as lazy-sorted-map except that its a
   function and it takes a seq of keys-delayed-value pairs."
   [& kvs]
   (LazyMap. (apply sorted-map kvs)))
 
 (defmacro lazy-sorted-map
-  "<lazy-sorted-map> creates a map. The values are not evaluated before their
+  "lazy-sorted-map creates a map. The values are not evaluated before their
   first retrieval. Each value is evaluated at most once. The underlying map
   is a sorted map."
   [& kvs]
   `(lazy-sorted-map* ~@(quote-values kvs)))
 
 (defn lazy-struct-map*
-  "<lazy-struct-map*> is the same as <lazy-struct-map> except that its a
+  "lazy-struct-map* is the same as lazy-struct-map except that its a
   function and it takes a seq of keys-delayed-value pairs together with the
   struct basis."
   [s & kvs]
   (LazyMap. (apply struct-map s kvs)))
 
 (defmacro lazy-struct-map
-  "<lazy-struct-map> creates a map. The values are not evaluated before their
+  "lazy-struct-map creates a map. The values are not evaluated before their
   first retrieval. Each value is evaluated at most once. The underlying map
   is a struct map according to the provided structure s."
   [s & kvs]
   `(lazy-struct-map* ~s ~@(quote-values kvs)))
 
 (defn lazy-struct*
-  "<lazy-struct*> is the same as <lazy-struct> except that its a function and
+  "lazy-struct* is the same as lazy-struct except that its a function and
   it takes a seq of delayed value together with the struct basis."
   [s & vs]
   (LazyMap. (apply struct s vs)))
 
 (defmacro lazy-struct
-  "<lazy-struct> creates a map. The values are not evaluated before their
+  "lazy-struct creates a map. The values are not evaluated before their
   first retrieval. Each value is evaluated at most once. The underlying map
   is a struct map according to the provided structure s. As with Clojure's
-  <struct> the values have to appear in the order of the keys in the structure."
+  struct the values have to appear in the order of the keys in the structure."
   [s & vs]
   (let [vs (map (fn [v] `(delay ~v)) vs)]
     `(lazy-struct* ~s ~@vs)))