Liking cljdoc? Tell your friends :D

io.simplect.compose


>->>clj

(>->> 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>
sourceraw docstring

>>->clj

(>>-> 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>
sourceraw docstring

Cclj

(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]].
sourceraw docstring

cclj

(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.
sourceraw docstring

call-ifclj

(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.
sourceraw docstring

currycljmacro

(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]].
sourceraw docstring

def-cljmacro

(def- nm form)
(def- nm docstring form)

Like [[clojure.core/def]] except nm is private.

Like [[clojure.core/def]] except `nm` is private.
sourceraw docstring

fdefcljmacro

(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>
sourceraw docstring

fdef-cljmacro

(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.
sourceraw docstring

fmapcljmultimethod

(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.
sourceraw docstring

invokecljmacro

(invoke f & args)

Call function f.

Call function `f`.
sourceraw docstring

mclj

(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.
sourceraw docstring

pclj

(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.
sourceraw docstring

Pclj

(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`.
sourceraw docstring

rclj

(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.
sourceraw docstring

raptialclj

(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`.
sourceraw docstring

rcompclj

(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]].
sourceraw docstring

redefncljmacro

(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.
sourceraw docstring

reorderclj

(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>
sourceraw docstring

sdefncljmacro

(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
```
sourceraw docstring

sdefn-cljmacro

(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.
sourceraw docstring

Γclj

(Γ & 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]].
sourceraw docstring

γclj

(γ)
(γ 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.
sourceraw docstring

λcljmacro

(λ & 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
sourceraw docstring

μclj

(μ 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.
sourceraw docstring

πclj

(π 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.
sourceraw docstring

Πclj

(Π 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`.
sourceraw docstring

ρclj

(ρ 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.
sourceraw docstring

χcljmacro

(χ & 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]].
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close