Liking cljdoc? Tell your friends :D

excel-clj.tree

A key-value tree for Excel (accounting) data. The format is [Label [Children]] for nodes and [Label {:column :value}] for leaves.

For some example code, check out the various (comment ...) blocks in this namespace.

A key-value tree for Excel (accounting) data. The format is
[Label [Children]] for nodes and [Label {:column :value}] for leaves.

For some example code, check out the various (comment ...) blocks in this
namespace.
raw docstring

accounting-tableclj

(accounting-table trees
                  &
                  {:keys [aggregate-with min-leaf-depth]
                   :or {aggregate-with sum-maps min-leaf-depth 2}})

Render a coll of trees into a coll of tabular maps, where leaf values are listed on the same line and aggregated below into a total (default aggregation is addition).

Each item in the coll is a map with ::depth, ::label, ::header?, and ::total? attributes, in addition to the attributes in the leaves.

If an :aggregate-with function is provided, total lines are constructed by reducing that function over sub-leaves. Defaults to a reducing with sum-maps.

Render a coll of trees into a coll of tabular maps, where leaf values are
listed on the same line and aggregated below into a total (default aggregation
is addition).

Each item in the coll is a map with ::depth, ::label, ::header?, and ::total?
attributes, in addition to the attributes in the leaves.

If an `:aggregate-with` function is provided, total lines are constructed by
reducing that function over sub-leaves. Defaults to a reducing with `sum-maps`.
sourceraw docstring

childrenclj

(children node)

The node's children, or [] in the case of a leaf.

The node's children, or [] in the case of a leaf.
sourceraw docstring

headersclj

(headers tree first-hs last-hs)

Return a vector of headers in the tree, with any headers given in first-hs at the beginning and and in last-hs in order.

Return a vector of headers in the tree, with any headers given in first-hs
at the beginning and and in last-hs in order.
sourceraw docstring

labelclj

The label for a node.

The label for a node.
sourceraw docstring

leaf?clj

Is the node a leaf?

Is the node a leaf?
sourceraw docstring

mathcljmacro

(math form)

Any calls to + or - within form are modified to work on trees and tree values (maps of numbers).

Any calls to + or - within form are modified to work on trees and tree
values (maps of numbers).
sourceraw docstring

merge-treesclj

(merge-trees root-label & trees)

Merge the children of the provided trees under a single root.

Merge the children of the provided trees under a single root.
sourceraw docstring

mock-balance-sheetclj

source

negate-mapclj

(negate-map m)
source

negate-treeclj

(negate-tree tree)

Negate all of the numbers in a tree.

Negate all of the numbers in a tree.
sourceraw docstring

ordered-group-byclj

(ordered-group-by f xs)

Like group-by, but returns a [k [v]] seq and doesn't rearrange values except to include them in a group. Probably less performant because it has to search the built up seq to find the proper key-value store.

Like `group-by`, but returns a [k [v]] seq and doesn't rearrange values except
to include them in a group. Probably less performant because it has to search
the built up seq to find the proper key-value store.
sourceraw docstring

(print-table xs)
(print-table xs {:keys [ks empty-str pad-width]})

Display tabular data in a way that preserves label indentation in a way the clojure.pprint/print-table does not.

Display tabular data in a way that preserves label indentation in a way the
clojure.pprint/print-table does not.
sourceraw docstring

renderclj

(render table-items & {:keys [indent-width] :or {indent-width 2}})

Given a coll of table items with a qualified ::depth and ::label keys, return a table items indenting labels with ::depth and keeping other keys as column labels, removing namespace qualified keywords.

(Used for printing in a string, rather than with Excel.)

Given a coll of table items with a qualified ::depth and ::label keys, return
a table items indenting labels with ::depth and keeping other keys as column
labels, removing namespace qualified keywords.

(Used for printing in a string, rather than with Excel.)
sourceraw docstring

shallowclj

(shallow tree)

'Shallow' the tree one level by getting rid of the root and combining its children. Doesn't modify a leaf.

'Shallow' the tree one level by getting rid of the root and combining its
children. Doesn't modify a leaf.
sourceraw docstring

subtract-mapsclj

(subtract-maps m1 m2)
(subtract-maps m1 m2 & ms)

Very important difference from (merge-with - ...):

(merge-with - {:foo 10} {:foo 5 :bar 5}) ; => {:foo 5, :bar 5}

(subtract-maps {:foo 10} {:foo 5 :bar 5}) ; => {:foo 5, :bar -5}

Very important difference from (merge-with - ...):

(merge-with - {:foo 10} {:foo 5 :bar 5})
; => {:foo 5, :bar 5}

(subtract-maps {:foo 10} {:foo 5 :bar 5})
; => {:foo 5, :bar -5}
sourceraw docstring

sum-mapsclj

(sum-maps m1 m2)
(sum-maps m1 m2 & ms)

Similar to (merge-with + ...) but treats nil keys as 0 values.

Similar to (merge-with + ...) but treats nil keys as 0 values.
sourceraw docstring

table->treesclj

(table->trees tabular format-leaf & node-fns)

Collapse a tabular collection of maps into a collection of trees, where the label at each level of the tree is given by each of node-fns and the columns displayed are the result of format-leaf, which returns a tabular map.

See the (comment ...) block under this method declaration for an example.

Collapse a tabular collection of maps into a collection of trees, where the
label at each level of the tree is given by each of `node-fns` and the columns
displayed are the result of `format-leaf`, which returns a tabular map.

See the (comment ...) block under this method declaration for an example.
sourceraw docstring

unaggregated-tableclj

(unaggregated-table trees)

Similar to account-table, but makes no attempt to aggregate non-leaf headers, and accepts a coll of trees.

Similar to account-table, but makes no attempt to aggregate non-leaf headers,
and accepts a coll of trees.
sourceraw docstring

valueclj

(value tree)
(value tree reducing-fn)

Aggregate all of the leaf maps in tree by reducing over them with reducing-fn (defaults to summing maps together). If given a single map, returns the map.

Aggregate all of the leaf maps in `tree` by reducing over them with
`reducing-fn` (defaults to summing maps together). If given a single
map, returns the map.
sourceraw docstring

walkclj

(walk f tree)
(walk f branch? children root)

Map f across all [label attrs] and [label [child]] nodes, depth-first.

Use with the same branch? and children functions that you'd give to tree-seq in order to build a tree of the format used by this namespace.

Map f across all [label attrs] and [label [child]] nodes, depth-first.

Use with the same `branch?` and `children` functions that you'd give to
`tree-seq` in order to build a tree of the format used by this namespace.
sourceraw docstring

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

× close