Liking cljdoc? Tell your friends :D

com.fulcrologic.fulcro.algorithms.core

Small, dependency-free clojure.core-like utilities used throughout Fulcro.

These were previously pulled in from taoensso.encore. Fulcro now provides its own faithful implementations so that the runtime/data layer has no dependency on encore at all (which also means babashka, whose built-in encore is partial/broken, needs no shim).

Nothing in here has anything to do with encore.

The if-let/when-let macros superset clojure.core: they support multiple bindings and unconditional :let bindings. catching is a terse cross-platform try/catch. map-vals/remove-vals/dissoc-in/nnil/compiling-cljs? mirror the encore fns of the same names.

Small, dependency-free `clojure.core`-like utilities used throughout Fulcro.

These were previously pulled in from `taoensso.encore`. Fulcro now provides its own
faithful implementations so that the runtime/data layer has no dependency on encore at
all (which also means babashka, whose built-in encore is partial/broken, needs no shim).

Nothing in here has anything to do with encore.

The `if-let`/`when-let` macros superset `clojure.core`: they support **multiple bindings**
and unconditional `:let` bindings. `catching` is a terse cross-platform `try/catch`.
`map-vals`/`remove-vals`/`dissoc-in`/`nnil`/`compiling-cljs?` mirror the encore fns of the
same names.
raw docstring

catchingcljmacro

(catching try-expr)
(catching try-expr error-sym catch-expr)
(catching try-expr error-sym catch-expr finally-expr)
(catching try-expr error-type error-sym catch-expr finally-expr)

Terse, cross-platform try/catch/finally. The catch-all clause catches Throwable under Clojure/babashka and :default under ClojureScript.

Arities (mirroring encore):

  • [try-expr] - returns nil on any error
  • [try-expr error-sym catch-expr]
  • [try-expr error-sym catch-expr finally-expr]
  • [try-expr error-type error-sym catch-expr finally-expr] - catch a specific type
Terse, cross-platform `try`/`catch`/`finally`. The catch-all clause catches `Throwable`
under Clojure/babashka and `:default` under ClojureScript.

Arities (mirroring encore):
- `[try-expr]`                                             - returns nil on any error
- `[try-expr error-sym catch-expr]`
- `[try-expr error-sym catch-expr finally-expr]`
- `[try-expr error-type error-sym catch-expr finally-expr]` - catch a specific type
sourceraw docstring

compiling-cljs?clj/s

(compiling-cljs?)

Returns true iff currently generating ClojureScript code (i.e. called from a macro being expanded by the cljs compiler). Always false under babashka (it cannot compile cljs) and at ClojureScript runtime.

Returns true iff currently generating ClojureScript code (i.e. called from a macro being
expanded by the cljs compiler). Always false under babashka (it cannot compile cljs) and at
ClojureScript runtime.
sourceraw docstring

dissoc-inclj/s

(dissoc-in m ks)
(dissoc-in m ks dissoc-k)
(dissoc-in m ks dissoc-k & more)

Dissociates within a nested map structure. [m ks] - dissoc the leaf key of path ks [m ks dissoc-k] - dissoc dissoc-k from the map at path ks [m ks dissoc-k more] - dissoc dissoc-k and each of more from the map at path ks Empty/absent paths are no-ops (the original map is returned).

Dissociates within a nested map structure.
  `[m ks]`               - dissoc the leaf key of path `ks`
  `[m ks dissoc-k]`      - dissoc `dissoc-k` from the map at path `ks`
  `[m ks dissoc-k more]` - dissoc `dissoc-k` and each of `more` from the map at path `ks`
Empty/absent paths are no-ops (the original map is returned).
sourceraw docstring

if-letcljmacro

(if-let bindings then)
(if-let bindings then else)

Supersets clojure.core/if-let: supports multiple bindings and unconditional :let bindings. Each non-:let binding must be truthy to proceed; otherwise else is evaluated.

(if-let [x       (find-x)
         :let [y (derive y x)]
         z       (find-z x y)]
  (use x y z)
  :none)
Supersets `clojure.core/if-let`: supports multiple bindings and unconditional `:let`
bindings. Each non-`:let` binding must be truthy to proceed; otherwise `else` is evaluated.

```
(if-let [x       (find-x)
         :let [y (derive y x)]
         z       (find-z x y)]
  (use x y z)
  :none)
```
sourceraw docstring

map-valsclj/s

(map-vals f m)

Returns m with (f v) applied to each value. Returns {} when m is nil.

Returns `m` with `(f v)` applied to each value. Returns `{}` when `m` is nil.
sourceraw docstring

nnilclj/s

(nnil)
(nnil x)
(nnil x y)
(nnil x y z)
(nnil x y z & more)

Returns the first non-nil argument, or nil. Note false counts as non-nil.

Returns the first non-nil argument, or nil. Note `false` counts as non-nil.
sourceraw docstring

remove-valsclj/s

(remove-vals pred m)

Returns m, removing every entry whose value satisfies pred. Returns {} when m is nil.

Returns `m`, removing every entry whose value satisfies `pred`. Returns `{}` when `m` is nil.
sourceraw docstring

when-letcljmacro

(when-let bindings & body)

Supersets clojure.core/when-let: supports multiple bindings and unconditional :let bindings (see if-let). Evaluates body only when every non-:let binding is truthy.

Supersets `clojure.core/when-let`: supports multiple bindings and unconditional `:let`
bindings (see `if-let`). Evaluates `body` only when every non-`:let` binding is truthy.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close