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

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.notation 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.notation` 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 to namespace.

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

fdefcljmacro

(fdef nm form)
(fdef nm specpred-or-docstring form)
(fdef nm specpred-or-spec docstring form)

Defines a function accepting a single value using def (instead of defn). The resulting function which is instrumented to be checked against specpred.

Example:

  user> (fdef my-add-3 int? (fn [x] (+ x 3)))
  user/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 accepting a single value using `def` (instead of `defn`).  The resulting
function which is instrumented to be checked against `specpred`.

Example:

      user> (fdef my-add-3 int? (fn [x] (+ x 3)))
      user/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

raptialclj

(raptial f & args1)

Like partial except it will insert the argument accepted by the returned function between first and second elements of args (as opposed to [[partial]] which adds the argument after those given to it).

Example:

      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.notation 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 between first
and second elements of `args` (as opposed to [[partial]] which adds the argument after those given
to it).

Example:
```
      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.notation` 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.notation 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.notation` defines the short-hand notation [[Γ]] for [[rcomp]] and
[[γ]] for [[clojure.core/comp]].
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)

Define instrumented function. Like [[clojure.core/defn]] but instruments function to be checked against spec.

Example:

  (sdefn add-to-int
    (s/cat :int int?)
    "Add 2 to `v` which must be an integer."
    [v]
    (+ v 2))

user> (add-to-int 4)
6
user> (try (add-to-int 4.0) (catch Exception _ :err))
:err
Define instrumented function.  Like [[clojure.core/defn]] but instruments function to be checked
against `spec`.

Example:
```
  (sdefn add-to-int
    (s/cat :int int?)
    "Add 2 to `v` which must be an integer."
    [v]
    (+ v 2))

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)

Define instrumented private function. Like [[clojure.core/defn]] but instruments private function to be checked against spec. See sdefn for example of use.

Define instrumented private function.  Like [[clojure.core/defn]] but instruments private function
to be checked against `spec`.  See [[sdefn]] for example of use.
sourceraw docstring

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

× close