Liking cljdoc? Tell your friends :D

commensura.discover

Read-only discovery over the registered units and dimensions — "what units have this dimension?", "search unit names", "what is this value?". These are queryable views over the registry (commensura.registry): every fn reflects live registrations and returns plain data — sorted vectors of names, or maps — never the internal atoms. Reach here instead of filtering the registry atoms by hand.

(require '[commensura.discover :as d] '[commensura.units :as u]) (d/search-units "volt") ;=> ["volt" "abvolt" "intvolt" "statvolt" "thermalvolt" "electronvolt"] (d/units-of-dimension u/foot) ;=> ["actus" "angstrom" … "foot" … "meter" … "mile" …] (all lengths) (d/describe (c/per u/mile u/hour)) ;=> {:value "1 mile/hour [velocity]" :dimensions {:length 1 :time -1} :dimension-name "velocity"}

Read-only discovery over the registered units and dimensions — "what units have this
dimension?", "search unit names", "what is this value?". These are *queryable views*
over the registry (`commensura.registry`): every fn reflects live registrations and
returns plain data — sorted vectors of names, or maps — never the internal atoms. Reach
here instead of filtering the registry atoms by hand.

  (require '[commensura.discover :as d] '[commensura.units :as u])
  (d/search-units "volt")            ;=> ["volt" "abvolt" "intvolt" "statvolt" "thermalvolt" "electronvolt"]
  (d/units-of-dimension u/foot)       ;=> ["actus" "angstrom" … "foot" … "meter" … "mile" …]  (all lengths)
  (d/describe (c/per u/mile u/hour))  ;=> {:value "1 mile/hour [velocity]" :dimensions {:length 1 :time -1} :dimension-name "velocity"}
raw docstring

describeclj

(describe x)

A plain-data description of a commensura unit or quantity — or a registered unit name (string), so (map describe (search-units "volt")) just works. For a string, the exact unit is resolved; an unknown name throws (with a did you mean?).

Returns a map with :value (display string), :dimensions (canonical dims), :dimension-name (the human name — matching units-of-dimension's input), :namespace (where a defunit unit was defined), and :doc (its docstring). Keys whose value would be nil are omitted, so the map stays tight — an unnamed base dimension drops :dimension-name; a unit not made with defunit (a currency fn, a resolver-minted unit, or a bare quantity) drops :namespace; a doc-less unit drops :doc.

A plain-data description of a commensura unit or quantity — or a registered unit *name*
(string), so `(map describe (search-units "volt"))` just works. For a string, the exact
unit is resolved; an unknown name throws (with a `did you mean?`).

Returns a map with `:value` (display string), `:dimensions` (canonical dims), `:dimension-name`
(the human name — matching `units-of-dimension`'s input), `:namespace` (where a `defunit` unit was
defined), and `:doc` (its docstring). Keys whose value would be nil are omitted, so the map stays
tight — an unnamed base dimension drops `:dimension-name`; a unit not made with `defunit` (a currency
fn, a resolver-minted unit, or a bare quantity) drops `:namespace`; a doc-less unit drops `:doc`.
sourceraw docstring

search-unitsclj

(search-units query)

Registered unit names matching query — a case-insensitive substring, or a regex Pattern (matched with re-find). A substring search is ranked by closeness to the query (edit distance, so an exact name leads and the tightest wrappers follow — "volt"volt, then abvolt, …); a regex, having no query string to rank against, is returned alphabetically. Reflects live registrations.

Registered unit names matching `query` — a case-insensitive substring, or a regex `Pattern`
(matched with `re-find`). A substring search is ranked by closeness to the query (edit distance,
so an exact name leads and the tightest wrappers follow — `"volt"` → `volt`, then `abvolt`, …);
a regex, having no query string to rank against, is returned alphabetically. Reflects live
registrations.
sourceraw docstring

units-of-dimensionclj

(units-of-dimension d)

Sorted names of registered units whose canonical dimensions equal d. d may be a dims-map ({:length 1}), a commensura unit/quantity/interval (its dimensions are used — an interval's parts share one dimension), or a human dimension name ("velocity"). Reflects live registrations.

Sorted names of registered units whose canonical dimensions equal `d`. `d` may be a dims-map
(`{:length 1}`), a commensura unit/quantity/interval (its dimensions are used — an interval's
parts share one dimension), or a human dimension name (`"velocity"`). Reflects live registrations.
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