(>->> f)
Returns a function which calls f
with arguments reordered such that the first argument is given
to f
as the last.
The name of the function is meant to suggest that f
is converted to fit into a '->' context by
mapping argument order from ->
-style (missing arg inserted first) to '->>'-style (missing arg
inserted last).
Can be called without arguments in which case a function reordering arguments is
returned (cf. ex3
in the example below).
Example:
user> (-> {:a 1}
(assoc :b 9)
((>->> map) str))
("[:a 1]" "[:b 9]")
user>
(let [f (fn [& args] args)
map> (>->> map)]
{:ex1 ((>->> f) 1 2 3 4 5),
:ex2 (-> (range 5)
((>->> map) (partial * 10)))
:ex3 (-> (range 5)
(map> (partial * 1000)))})
{:ex1 (2 3 4 5 1),
:ex2 (0 10 20 30 40),
:ex3 (0 1000 2000 3000 4000)}
user>
Returns a function which calls `f` with arguments reordered such that the first argument is given to `f` as the last. The name of the function is meant to suggest that `f` is converted to fit into a '->' context by mapping argument order from `->`-style (missing arg inserted first) to '->>'-style (missing arg inserted last). Can be called without arguments in which case a function reordering arguments is returned (cf. `ex3` in the example below). Example: user> (-> {:a 1} (assoc :b 9) ((>->> map) str)) ("[:a 1]" "[:b 9]") user> (let [f (fn [& args] args) map> (>->> map)] {:ex1 ((>->> f) 1 2 3 4 5), :ex2 (-> (range 5) ((>->> map) (partial * 10))) :ex3 (-> (range 5) (map> (partial * 1000)))}) {:ex1 (2 3 4 5 1), :ex2 (0 10 20 30 40), :ex3 (0 1000 2000 3000 4000)} user>
(>>-> f)
Returns a function which calls f
with arguments reordered such that last argument is given to f
as the first.
The name of the function is meant to suggest that f
is converted to fit into a '->>' context by
mapping argument order from ->>
-style (arg last) to '->'-style (arg first).
Can be called without arguments in which case a function reordering arguments is
returned (cf. ex3
in the example below).
Example:
user> (->> {:a 1}
((>>-> assoc) :b 1))
{:a 1, :b 1}
user> (let [f (fn [& args] args)
assoc>> (>>-> assoc)]
{:ex1 ((>>-> f) 1 2 3 4 5),
:ex2 (->> {:a 1}
((>>-> assoc) :b 2))
:ex3 (->> {:a 1}
(assoc>> :b 2))})
{:ex1 (5 1 2 3 4),
:ex2 {:a 1, :b 2},
:ex3 {:a 1, :b 2}}
user>
Returns a function which calls `f` with arguments reordered such that last argument is given to `f` as the first. The name of the function is meant to suggest that `f` is converted to fit into a '->>' context by mapping argument order from `->>`-style (arg last) to '->'-style (arg first). Can be called without arguments in which case a function reordering arguments is returned (cf. `ex3` in the example below). Example: user> (->> {:a 1} ((>>-> assoc) :b 1)) {:a 1, :b 1} user> (let [f (fn [& args] args) assoc>> (>>-> assoc)] {:ex1 ((>>-> f) 1 2 3 4 5), :ex2 (->> {:a 1} ((>>-> assoc) :b 2)) :ex3 (->> {:a 1} (assoc>> :b 2))}) {:ex1 (5 1 2 3 4), :ex2 {:a 1, :b 2}, :ex3 {:a 1, :b 2}} user>
(C & fs)
Notation for rcomp
.
Compose fs
in order. Like [[clojure.core/comp]] except applies fs
in the order they appear
(reverse order relative to [[comp]]). io.simplect.compose
defines the short-hand notation Γ
for rcomp
and γ
for [[clojure.core/comp]].
Notation for [[rcomp]]. Compose `fs` in order. Like [[clojure.core/comp]] except applies `fs` in the order they appear (reverse order relative to [[comp]]). `io.simplect.compose` defines the short-hand notation [[Γ]] for [[rcomp]] and [[γ]] for [[clojure.core/comp]].
(c)
(c f)
(c f g)
(c f g & fs)
Notation for [[core/comp]].
Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.
Notation for [[core/comp]]. Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.
(call-if pred f)
Takes a single argument. If applying pred
to the argument yields a truthy value returns the
result of applying f
to the argument, otherwise returns the argument itself.
Takes a single argument. If applying `pred` to the argument yields a truthy value returns the result of applying `f` to the argument, otherwise returns the argument itself.
(curry & args)
Same as cats.core/curry
from the Funcool Cats library, its docstring reproduced below for
convenience.
Given either a fixed arity function or an arity and a function, return another which is curried.
With inferred arity (function must have one fixed arity):
(defn add2 [x y] (+ x y))
(def cadd2 (curry add2))
((cadd2 1) 3)
;; => 4
(cadd2 1 3)
;; => 4
With given arity:
(def c+ (curry 3 +))
((c+ 1 2) 3)
;; => 6
((((c+) 1) 2) 3)
;; => 6
io.simplect.compose
defines the short-hand notation Χ
for curry
.
Same as `cats.core/curry` from the Funcool Cats library, its docstring reproduced below for convenience. Given either a fixed arity function or an arity and a function, return another which is curried. With inferred arity (function must have one fixed arity): (defn add2 [x y] (+ x y)) (def cadd2 (curry add2)) ((cadd2 1) 3) ;; => 4 (cadd2 1 3) ;; => 4 With given arity: (def c+ (curry 3 +)) ((c+ 1 2) 3) ;; => 6 ((((c+) 1) 2) 3) ;; => 6 `io.simplect.compose` defines the short-hand notation `Χ` for [[curry]].
(def- nm form)
(def- nm docstring form)
Like [[clojure.core/def]] except nm
is private.
Like [[clojure.core/def]] except `nm` is private.
(fdef nm form)
(fdef nm specpred-or-docstring form)
(fdef nm specpred-or-spec docstring form)
Defines a function with specification. The resulting function is NOT instrumented.
Example:
user> (fdef my-add-3 int? (fn [x] (+ x 3)))
user/my-add-3
user> (clojure.spec.test.alpha/instrument `my-add-3)
user> (my-add-3 2)
5
user> (my-add-3 2.0)
Execution error - invalid arguments to io.simplect.compose/my-add-3 at (REPL:5).
2.0 - failed: int? at: [:G__8490]
user>
Defines a function with specification. The resulting function is NOT instrumented. Example: user> (fdef my-add-3 int? (fn [x] (+ x 3))) user/my-add-3 user> (clojure.spec.test.alpha/instrument `my-add-3) user> (my-add-3 2) 5 user> (my-add-3 2.0) Execution error - invalid arguments to io.simplect.compose/my-add-3 at (REPL:5). 2.0 - failed: int? at: [:G__8490] user>
(fdef- nm form)
(fdef- nm specpred-or-docstring form)
(fdef- nm specpred docstring form)
Like fdef
except defines a private function.
Like [[fdef]] except defines a private function.
(fmap f s)
Notation for [[clojure.algo.generic.functor/fmap]].
Applies function f to each item in the data structure s and returns a structure of the same kind.
Notation for [[clojure.algo.generic.functor/fmap]]. Applies function f to each item in the data structure s and returns a structure of the same kind.
(m f)
(m f coll)
(m f c1 c2)
(m f c1 c2 c3)
(m f c1 c2 c3 & colls)
Notation for [[core/map]].
Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no collection is provided.
Notation for [[core/map]]. Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no collection is provided.
(p f)
(p f arg1)
(p f arg1 arg2)
(p f arg1 arg2 arg3)
(p f arg1 arg2 arg3 & more)
Notation for [[core/partial]].
Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args.
Notation for [[core/partial]]. Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args.
(P f & args)
Notation for raptial
.
Like partial
except it will insert the argument accepted by the returned function to the front
of args
(as opposed to [[partial]] which adds the argument after those given to it).
user> (let [f (c/raptial assoc :a 1)
g #(assoc % :a 1)
m {:b 2}]
(= (f m) (g m)))
true
user> {:ex1 ((raptial assoc :x 2) {:a 1})
:ex2 (->> [{:a 1} {:v -1}]
(map (raptial assoc :x 2)))}
{:ex1 {:a 1, :x 2},
:ex2 ({:a 1, :x 2} {:v -1, :x 2})}
user>
io.simplect.compose
defines the short-hand notation π
for raptial
and Π
for
clojure.core/partial
.
Notation for [[raptial]]. Like `partial` except it will insert the argument accepted by the returned function to the *front* of `args` (as opposed to [[partial]] which adds the argument *after* those given to it). ``` user> (let [f (c/raptial assoc :a 1) g #(assoc % :a 1) m {:b 2}] (= (f m) (g m))) true user> {:ex1 ((raptial assoc :x 2) {:a 1}) :ex2 (->> [{:a 1} {:v -1}] (map (raptial assoc :x 2)))} {:ex1 {:a 1, :x 2}, :ex2 ({:a 1, :x 2} {:v -1, :x 2})} user> ``` `io.simplect.compose` defines the short-hand notation `π` for `raptial` and `Π` for `clojure.core/partial`.
(r f coll)
(r f val coll)
Notation for [[core/reduce]].
f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. If coll contains no items, returns val and f is not called.
Notation for [[core/reduce]]. f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. If coll contains no items, returns val and f is not called.
(raptial f & args)
Like partial
except it will insert the argument accepted by the returned function to the front
of args
(as opposed to [[partial]] which adds the argument after those given to it).
user> (let [f (c/raptial assoc :a 1)
g #(assoc % :a 1)
m {:b 2}]
(= (f m) (g m)))
true
user> {:ex1 ((raptial assoc :x 2) {:a 1})
:ex2 (->> [{:a 1} {:v -1}]
(map (raptial assoc :x 2)))}
{:ex1 {:a 1, :x 2},
:ex2 ({:a 1, :x 2} {:v -1, :x 2})}
user>
io.simplect.compose
defines the short-hand notation π
for raptial
and Π
for
clojure.core/partial
.
Like `partial` except it will insert the argument accepted by the returned function to the *front* of `args` (as opposed to [[partial]] which adds the argument *after* those given to it). ``` user> (let [f (c/raptial assoc :a 1) g #(assoc % :a 1) m {:b 2}] (= (f m) (g m))) true user> {:ex1 ((raptial assoc :x 2) {:a 1}) :ex2 (->> [{:a 1} {:v -1}] (map (raptial assoc :x 2)))} {:ex1 {:a 1, :x 2}, :ex2 ({:a 1, :x 2} {:v -1, :x 2})} user> ``` `io.simplect.compose` defines the short-hand notation `π` for `raptial` and `Π` for `clojure.core/partial`.
(rcomp & fs)
Compose fs
in order. Like [[clojure.core/comp]] except applies fs
in the order they appear
(reverse order relative to [[comp]]). io.simplect.compose
defines the short-hand notation Γ
for rcomp
and γ
for [[clojure.core/comp]].
Compose `fs` in order. Like [[clojure.core/comp]] except applies `fs` in the order they appear (reverse order relative to [[comp]]). `io.simplect.compose` defines the short-hand notation [[Γ]] for [[rcomp]] and [[γ]] for [[clojure.core/comp]].
(redefn name refname)
Defines name
to be refname
and updates its meta-data keys :arglists
and :doc
to be those of
refname
thereby enabling tools to show its argument lists and documentation. Useful for
functions.
Defines `name` to be `refname` and updates its meta-data keys `:arglists` and `:doc` to be those of `refname` thereby enabling tools to show its argument lists and documentation. Useful for functions.
(reorder v f)
Returns a function which calls f
with arguments reordered according to v
which must be a
sequential collection of integers all less than the number of arguments.
Example:
user> (let [f (fn [& args] args)
g (reorder [0 3 2 0] f)]
(g :a :b :c :d :e))
(:a :d :c :a)
user>
Returns a function which calls `f` with arguments reordered according to `v` which must be a sequential collection of integers all less than the number of arguments. Example: user> (let [f (fn [& args] args) g (reorder [0 3 2 0] f)] (g :a :b :c :d :e)) (:a :d :c :a) user>
(sdefn nm spec docstring arglist & body)
Defines a functions like [[clojure.core/defn]] but adds specification spec
. Note that the
function is NOT instrumented.
Example: ```
(sdefn add-to-int
(s/cat :int int?)
"Add 2 to v
which must be an integer."
[v]
(+ v 2))
(clojure.spec.alpha/instrument `add-to-int)
user> (add-to-int 4) 6 user> (try (add-to-int 4.0) (catch Exception _ :err)) :err
Defines a functions like [[clojure.core/defn]] but adds specification `spec`. Note that the function is NOT instrumented. Example: ``` (sdefn add-to-int (s/cat :int int?) "Add 2 to `v` which must be an integer." [v] (+ v 2)) (clojure.spec.alpha/instrument `add-to-int) user> (add-to-int 4) 6 user> (try (add-to-int 4.0) (catch Exception _ :err)) :err ```
(sdefn- nm spec docstring arglist & body)
Defines private function like [[clojure.core/defn]] but adds specification spec
.
See sdefn
for example of use. Note that function is NOT instrumented.
Defines private function like [[clojure.core/defn]] but adds specification `spec`. See [[sdefn]] for example of use. Note that function is NOT instrumented.
(Γ & fs)
Notation for rcomp
.
Compose fs
in order. Like [[clojure.core/comp]] except applies fs
in the order they appear
(reverse order relative to [[comp]]). io.simplect.compose
defines the short-hand notation Γ
for rcomp
and γ
for [[clojure.core/comp]].
Notation for [[rcomp]]. Compose `fs` in order. Like [[clojure.core/comp]] except applies `fs` in the order they appear (reverse order relative to [[comp]]). `io.simplect.compose` defines the short-hand notation [[Γ]] for [[rcomp]] and [[γ]] for [[clojure.core/comp]].
(γ)
(γ f)
(γ f g)
(γ f g & fs)
Notation for [[core/comp]].
Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.
Notation for [[core/comp]]. Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc.
(λ & sigs)
Abbreviated form of [[clojure.core/fn]].
params => positional-params* , or positional-params* & next-param positional-param => binding-form next-param => binding-form name => symbol
Defines a function
Abbreviated form of [[clojure.core/fn]]. params => positional-params* , or positional-params* & next-param positional-param => binding-form next-param => binding-form name => symbol Defines a function
(μ f)
(μ f coll)
(μ f c1 c2)
(μ f c1 c2 c3)
(μ f c1 c2 c3 & colls)
Notation for [[core/map]].
Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no collection is provided.
Notation for [[core/map]]. Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments. Returns a transducer when no collection is provided.
(π f)
(π f arg1)
(π f arg1 arg2)
(π f arg1 arg2 arg3)
(π f arg1 arg2 arg3 & more)
Notation for [[core/partial]].
Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args.
Notation for [[core/partial]]. Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args.
(Π f & args)
Notation for raptial
.
Like partial
except it will insert the argument accepted by the returned function to the front
of args
(as opposed to [[partial]] which adds the argument after those given to it).
user> (let [f (c/raptial assoc :a 1)
g #(assoc % :a 1)
m {:b 2}]
(= (f m) (g m)))
true
user> {:ex1 ((raptial assoc :x 2) {:a 1})
:ex2 (->> [{:a 1} {:v -1}]
(map (raptial assoc :x 2)))}
{:ex1 {:a 1, :x 2},
:ex2 ({:a 1, :x 2} {:v -1, :x 2})}
user>
io.simplect.compose
defines the short-hand notation π
for raptial
and Π
for
clojure.core/partial
.
Notation for [[raptial]]. Like `partial` except it will insert the argument accepted by the returned function to the *front* of `args` (as opposed to [[partial]] which adds the argument *after* those given to it). ``` user> (let [f (c/raptial assoc :a 1) g #(assoc % :a 1) m {:b 2}] (= (f m) (g m))) true user> {:ex1 ((raptial assoc :x 2) {:a 1}) :ex2 (->> [{:a 1} {:v -1}] (map (raptial assoc :x 2)))} {:ex1 {:a 1, :x 2}, :ex2 ({:a 1, :x 2} {:v -1, :x 2})} user> ``` `io.simplect.compose` defines the short-hand notation `π` for `raptial` and `Π` for `clojure.core/partial`.
(ρ f coll)
(ρ f val coll)
Notation for [[core/reduce]].
f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. If coll contains no items, returns val and f is not called.
Notation for [[core/reduce]]. f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val is supplied, returns the result of applying f to val and the first item in coll, then applying f to that result and the 2nd item, etc. If coll contains no items, returns val and f is not called.
(χ & args)
Abbreviated form of io.simplect.compose/curry
.
Same as cats.core/curry
from the Funcool Cats library, its docstring reproduced below for
convenience.
Given either a fixed arity function or an arity and a function, return another which is curried.
With inferred arity (function must have one fixed arity):
(defn add2 [x y] (+ x y))
(def cadd2 (curry add2))
((cadd2 1) 3)
;; => 4
(cadd2 1 3)
;; => 4
With given arity:
(def c+ (curry 3 +))
((c+ 1 2) 3)
;; => 6
((((c+) 1) 2) 3)
;; => 6
io.simplect.compose
defines the short-hand notation Χ
for curry
.
Abbreviated form of [[io.simplect.compose/curry]]. Same as `cats.core/curry` from the Funcool Cats library, its docstring reproduced below for convenience. Given either a fixed arity function or an arity and a function, return another which is curried. With inferred arity (function must have one fixed arity): (defn add2 [x y] (+ x y)) (def cadd2 (curry add2)) ((cadd2 1) 3) ;; => 4 (cadd2 1 3) ;; => 4 With given arity: (def c+ (curry 3 +)) ((c+ 1 2) 3) ;; => 6 ((((c+) 1) 2) 3) ;; => 6 `io.simplect.compose` defines the short-hand notation `Χ` for [[curry]].
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close