Contains functions. These are:
list-varpar-exptnotns-in-subformulaexpts-in-subformulanames-in-subformulanext-subformula-components-with-common-notationremove-zero-powers(require '[diman.filter :refer [list-varpar-expt notns-in-subformula
expts-in-subformula names-in-subformula
next-subformula-components-with-common-notation
remove-zero-powers]])
Given an expression
(def expr "0.5*a^(1)*t^(2)")
the variable/parameter and corresponding exponents can be filtered out as
=> (list-varpar-expt expr)
[("a" "t") ("1" "2")]
A sub-formula (special case of dimensional formula)
(def subform1 "[M^(0)*L^(1)*T^(-2)]")
is also an expression. Therefore,
=> (list-varpar-expt "M^(0)*L^(1)*T^(-2)")
[("M" "L" "T") ("0" "1" "-2")]
Similarly, for (def subform2 "[M^(2/3)*cd^(1)*mol^(-2)]")
=> (list-varpar-expt (remove-brackets subform2))
[("M" "cd" "mol") ("2/3" "1" "-2")]
For the same subform2 defined above
=> (notns-in-subformula subform2)
("M" "cd" "mol")
and
=> (expts-in-subformula subform2)
("2/3" "1" "-2")
The names of the notations are
=> (names-in-subformula subform2)
("mass" "luminous intensity" "amount of substance")
For (def lsubform '("[M^(0)*L^(1)*T^(-2)]" "[A^(1)*T^(2)]" "[cd]^(0)*[mol]^(-2)]"))
consider "[M^(0)*L^(1)*T^(-2)]" to be the reference sub-formula (because it has the
largest number of unique notations). Component in the next sub-formula "[A^(1)*T^(2)]"
with common notation is given in formula representation as
=> (next-subformula-components-with-common-notation (first lsubform) (second lsubform))
"[T^(2)]"
and if "[cd]^(0)*[mol]^(-2)]" is the next component
=> (next-subformula-components-with-common-notation (first lsubform) (last lsubform))
nil
and with itself
=> (next-subformula-components-with-common-notation (first lsubform) (first lsubform))
nil
For (def subformula "[T^(0)*L^(1)]") and
(def formula "[L^(1)] + [T^(-2)*L^(2)] + [T^(1)] + [T^(0)*L^(1)]")
their reduced forms are
=> (remove-zero-powers subformula)
"[L^(1)]"
and
=> (remove-zero-powers formula)
"[L^(1)] + [T^(-2)*L^(2)] + [T^(1)] + [L^(1)]"
Contains functions.
These are:
- `list-varpar-expt`
- `notns-in-subformula`
- `expts-in-subformula`
- `names-in-subformula`
- `next-subformula-components-with-common-notation`
- `remove-zero-powers`
## How to use
### Loading
```
(require '[diman.filter :refer [list-varpar-expt notns-in-subformula
expts-in-subformula names-in-subformula
next-subformula-components-with-common-notation
remove-zero-powers]])
```
### Examples
#### Filter out the variable/parameter and its exponents separately
Given an expression
```(def expr "0.5*a^(1)*t^(2)")```
the variable/parameter and corresponding exponents can be filtered out as
```
=> (list-varpar-expt expr)
[("a" "t") ("1" "2")]
```
#### Filtering out one of the seven fundamental notations and its exponents
A sub-formula (special case of dimensional formula)
```(def subform1 "[M^(0)*L^(1)*T^(-2)]")```
is also an expression. Therefore,
```
=> (list-varpar-expt "M^(0)*L^(1)*T^(-2)")
[("M" "L" "T") ("0" "1" "-2")]
```
Similarly, for `(def subform2 "[M^(2/3)*cd^(1)*mol^(-2)]")`
```
=> (list-varpar-expt (remove-brackets subform2))
[("M" "cd" "mol") ("2/3" "1" "-2")]
```
#### Filter out the notations, notations names in a sub-formula and also its corresponding exponents
For the same `subform2` defined above
```
=> (notns-in-subformula subform2)
("M" "cd" "mol")
```
and
```
=> (expts-in-subformula subform2)
("2/3" "1" "-2")
```
The names of the notations are
```
=> (names-in-subformula subform2)
("mass" "luminous intensity" "amount of substance")
```
#### Filter out recurring notation of component/s in next sub-formula w.r.t reference sub-formula
For `(def lsubform '("[M^(0)*L^(1)*T^(-2)]" "[A^(1)*T^(2)]" "[cd]^(0)*[mol]^(-2)]"))`
consider `"[M^(0)*L^(1)*T^(-2)]"` to be the reference sub-formula (because it has the
largest number of unique notations). Component in the next sub-formula `"[A^(1)*T^(2)]"`
with common notation is given in formula representation as
```
=> (next-subformula-components-with-common-notation (first lsubform) (second lsubform))
"[T^(2)]"
```
and if `"[cd]^(0)*[mol]^(-2)]"` is the next component
```
=> (next-subformula-components-with-common-notation (first lsubform) (last lsubform))
nil
```
and with itself
```
=> (next-subformula-components-with-common-notation (first lsubform) (first lsubform))
nil
```
#### Filtering out base notations having zero exponents in a sub-formula or the formula for a side of the equation.
For `(def subformula "[T^(0)*L^(1)]")` and
`(def formula "[L^(1)] + [T^(-2)*L^(2)] + [T^(1)] + [T^(0)*L^(1)]")`
their reduced forms are
```
=> (remove-zero-powers subformula)
"[L^(1)]"
```
and
```
=> (remove-zero-powers formula)
"[L^(1)] + [T^(-2)*L^(2)] + [T^(1)] + [L^(1)]"
```
(list-varpar-expt x)(list-varpar-expt x lst_varpars lst_expts)Returns list with two nested lists for a given expression; first is list of variables/parameters last is the list of its corresponding exponent values.
Returns list with two nested lists for a given expression; first is list of variables/parameters last is the list of its corresponding exponent values.
(names-in-subformula subform)(names-in-subformula subform lst_notns lst_names)Returns list of names in the formula component (same order as the formula).
Returns list of names in the formula component (same order as the formula).
(next-subformula-components-with-common-notation ref_subform next_subform)(next-subformula-components-with-common-notation ref_subform
lst_ref_notns
lst_next_notns
lst_next_expts
matched_component)Returns formula within the next component having the same notation as its reference.
Returns formula within the next component having the same notation as its reference.
(remove-zero-powers eqn_form)(remove-zero-powers eqn_form lst_subform lst_ans)Returns the reduced dimensional formula, i.e. base notations with zero exponents are removed.
Returns the reduced dimensional formula, i.e. base notations with zero exponents are removed.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |