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-settable
function invocation when they appear in the first element in an S-expression.
The toString method is also dynamically settable to indicate that the
vectors are altered. All other behaviors are identical to Clojure's built-in
persistent 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 invocation 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-settable
function invocation when they appear in the first element in an S-expression.
The `toString` method is also dynamically settable to indicate that the
vectors are altered. All other behaviors are identical to Clojure's built-in
persistent 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 invocation 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.
Example:
(alt-fn-vec #{1 2 3}) ;; => [1 3 2]
Creates a new vector containing the contents of collection `c`.
Analogous to [`clojure.core/vec`](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/vec)
, but does not currently handle Java arrays in the same manner.
Example:
```clojure
(alt-fn-vec #{1 2 3}) ;; => [1 3 2]
```(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.
Example:
(alt-fn-vector 1 2 3) ;; => [1 2 3]
Creates a new vector containing the args. The returned vector has a modifiable function behavior (defaults to `nth`). Analogous to [`clojure.core/vector`](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/vector). Example: ``` (alt-fn-vector 1 2 3) ;; => [1 2 3] ```
A defonce-d map with keys :fn, :left-delimiter, and :right-delimiter.
A `defonce`-d map with keys `:fn`, `:left-delimiter`, and `:right-delimiter`.
(defaultize!-options)Resets options map to default values. See default-options.
Resets options map to default values. See [[default-options]].
(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 stringResets options to map `m`. `m` must associate the following key-vals: * `:fn` a function * `:left-delimiter` a string * `:right-delimiter` a string
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |