WARNING: Unless you are the author of this library, you almost certainly don't want to use this namespace. The items provided here diverge from typical Clojure semantics and are intended for a very specific case that is unusual. All other uses are strongly discouraged.
This namespace provides instances of vectors with dynamically-setable function
invocation when they appear in the first element in an S-expression. The
toString
method is also dynamically setable to indicate that the vectors
are altered. All other behaviors are identical to Clojure's built-in persitent
vectors.
Examples
(def normal-vector (vector 1 2 3))
(def dangerous-vector (alt-fn-vector 1 2 3))
;; shares standard behavior
(count normal-vector) ;; 3
(count dangerous-vector) ;; 3
Change the invocaton function.
(reset!-options {:fn (fn [v1 v2] (concat v1 v2))
:left-delimiter "⟨"
:right-delimiter "⟩"})
Now, the invoke
and toString
behavior is altered.
(dangerous-vector [97 98 99]) ;; (1 2 3 97 98 99)
(.toString dangerous-vector) ;; "⟨1 2 3⟩"
WARNING: Unless you are the author of this library, you almost certainly don't want to use this namespace. The items provided here diverge from typical Clojure semantics and are intended for a very specific case that is unusual. All other uses are strongly discouraged. This namespace provides instances of vectors with dynamically-setable function invocation when they appear in the first element in an S-expression. The `toString` method is also dynamically setable to indicate that the vectors are altered. All other behaviors are identical to Clojure's built-in persitent vectors. Examples ```clojure (def normal-vector (vector 1 2 3)) (def dangerous-vector (alt-fn-vector 1 2 3)) ;; shares standard behavior (count normal-vector) ;; 3 (count dangerous-vector) ;; 3 ``` Change the invocaton function. ```clojure (reset!-options {:fn (fn [v1 v2] (concat v1 v2)) :left-delimiter "⟨" :right-delimiter "⟩"}) ``` Now, the `invoke` and `toString` behavior is altered. ```clojure (dangerous-vector [97 98 99]) ;; (1 2 3 97 98 99) (.toString dangerous-vector) ;; "⟨1 2 3⟩" ```
(alt-fn-vec c)
Creates a new vector containing the contents of collection c
.
Analogous to clojure.core.vec
, but does not currently handle Java arrays in
the same manner.
Creates a new vector containing the contents of collection `c`. Analogous to `clojure.core.vec`, but does not currently handle Java arrays in the same manner.
(alt-fn-vector)
(alt-fn-vector a)
(alt-fn-vector a b)
(alt-fn-vector a b c)
(alt-fn-vector a b c d)
(alt-fn-vector a b c d e)
(alt-fn-vector a b c d e f)
(alt-fn-vector a b c d e f & args)
Creates a new vector containing the args. The returned vector has a
modifiable function behavior (defaults to nth
).
Analogous to clojure.core.vector
.
Creates a new vector containing the args. The returned vector has a modifiable function behavior (defaults to `nth`). Analogous to `clojure.core.vector`.
(defaultize!-options)
Resets options map to default values. See default-options
.
Resets options map to default values. See [[default-options]].
(options-validator m)
Given hash-map m
, returns true
if the :fn
value is a function, and if
the :left-delimiter
and :right-delimiter
values are strings.
Given hash-map `m`, returns `true` if the `:fn` value is a function, and if the `:left-delimiter` and `:right-delimiter` values are strings.
(reset!-options m)
Resets options to map m
. m
must associate the following key-vals:
:fn
a function:left-delimiter
a string:right-delimiter
a stringNote: m
must be coerced into a clojure.lang.PersistentHashMap.
Resets options to map `m`. `m` must associate the following key-vals: * `:fn` a function * `:left-delimiter` a string * `:right-delimiter` a string Note: `m` must be coerced into a clojure.lang.PersistentHashMap.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close