Liking cljdoc? Tell your friends :D

relation-utils.core

As Clojure programmers, transforming collections of maps is our bread and butter. clojure.set encourages us to treat such collections as relations. Plenty of benefits await:

  1. Bring strong keywords front and center, helping clarity
  2. Maintain provenance throughout the transformation
  3. Decomplect computation from relational structure
  4. Avoid join-like operations with implicit ordering dependencies
As Clojure programmers, transforming collections of maps is
our bread and butter. clojure.set encourages us to treat such
collections as relations. Plenty of benefits await:

1. Bring strong keywords front and center, helping clarity
2. Maintain provenance throughout the transformation
3. Decomplect computation from relational structure
4. Avoid join-like operations with implicit ordering dependencies
raw docstring

deriveclj

(derive dest-attr f)
(derive dest-attr f xrel & args)

Maps a tuple operation over the relation, associng the result as a new attribute. This allows us to non-destructively derive information from tuples using regular, 'destructive' functions.

Maps a tuple operation over the relation, associng the result as a
new attribute. This allows us to non-destructively derive
information from tuples using regular, 'destructive' functions.
sourceraw docstring

derive-kclj

(derive-k dest-attr f ks)
(derive-k dest-attr f ks xrel)

Corresponds to SELECT F(key, key2, ...)

Corresponds to SELECT F(key, key2, ...)
sourceraw docstring

matches-specmap?clj

(matches-specmap? specmap m)
source

project-outclj

(project-out k xrel)
(project-out fadd k xrel)

Given a relation xrel with free variables V ∪ {k}, returns a map from tuples projected to V∖{k} to bound values of k. Duplicates are merged using the provided fadd function.

Given a relation `xrel` with free variables V ∪ {k}, returns a map
from tuples projected to V∖{k} to bound values of k. Duplicates are
merged using the provided `fadd` function.
sourceraw docstring

reduce-byclj

(reduce-by key-fn xf init-fn xrel)

Like reduce, but allows for a separate accumulator per group.

Threading becomes a mess, whenever the structure of the data changes during the transform. This is especially annoying with groupings. But we can do better in many cases, when we are not interested in a specific group, but rather in processing all of them.

In such a case we can reduce over the relation and keep one accumulator per group.

Like reduce, but allows for a separate accumulator per
group.

Threading becomes a mess, whenever the structure of the data changes
during the transform. This is especially annoying with
groupings. But we can do better in many cases, when we are not
interested in a specific group, but rather in processing all of
them.

In such a case we can reduce over the relation and keep one
accumulator per group.
sourceraw docstring

relateclj

(relate & pairs)

Lift unkeyed data into a relation.

Lift unkeyed data into a relation.
sourceraw docstring

select-complementclj

(select-complement map keyseq)

Returns a rel of the elements of xrel with keys in ks dissoced. Inverse of clojure.core/select-keys.

Returns a rel of the elements of xrel with keys in ks
dissoced. Inverse of clojure.core/select-keys.
sourceraw docstring

whereclj

(where specmap)
(where specmap xset)

Returns a set of the elements conforming to the given spec-map. A spec-map is a way to quickly combine specs into a tuple filter.

Example

{:x #(= % 10) :y #(< % 100)} matches all tuples where (= x 10) and (< y 100).

Returns a set of the elements conforming to the given spec-map. A
spec-map is a way to quickly combine specs into a tuple filter.

Example
=======
{:x #(= % 10) :y #(< % 100)} matches all tuples where (= x 10) and (< y 100).
sourceraw docstring

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

× close