This namespace contains a number of functions and utilities for manipulating and comparing raw symbolic expression trees.
Also included is an implementation of a [[Literal]] type that forms the basis
for emmy.abstract.number/literal-number
.
This namespace contains a number of functions and utilities for manipulating and comparing raw symbolic expression trees. Also included is an implementation of a [[Literal]] type that forms the basis for [[emmy.abstract.number/literal-number]].
These keywords reference 'abstract' types that stand in for some concrete data type in the system.
These keywords reference 'abstract' types that stand in for some concrete data type in the system.
(abstract? x)
Returns true if x
is both a [[Literal]] and has a type specified
in abstract-types
, false otherwise.
Returns true if `x` is both a [[Literal]] and has a type specified in [[abstract-types]], false otherwise.
(compare l r)
Comparator for expressions. The rule is that types have the following ordering:
Any types not in this list compare with the other type using hashes.
Comparator for expressions. The rule is that types have the following ordering: - empty sequence is < anything (except another empty seq) - real < symbol < string < sequence - sequences compare element-by-element Any types _not_ in this list compare with the other type using hashes.
(evaluate expr sym->var sym->f)
Walk the unwrapped expression expr
in postorder, replacing symbols found
there with their values in the sym->var
mapping, if present.
sym->f
is used for elements in function application position (first of a
sequence).
Walk the unwrapped expression `expr` in postorder, replacing symbols found there with their values in the `sym->var` mapping, if present. `sym->f` is used for elements in function application position (first of a sequence).
(expression->stream expr stream)
(expression->stream expr stream options)
Renders an expression through the simplifier and onto the stream.
Renders an expression through the simplifier and onto the stream.
(expression->string expr)
Returns a string representation of a frozen, simplified version of the supplied
expression expr
.
Returns a string representation of a frozen, simplified version of the supplied expression `expr`.
(expression-of expr)
If the supplied argument is a [[Literal]] (or a symbol, interpreted elsewhere as a numerical literal expression), returns the wrapped expression (or the symbol).
Else, returns expr
.
If the supplied argument is a [[Literal]] (or a symbol, interpreted elsewhere as a numerical literal expression), returns the wrapped expression (or the symbol). Else, returns `expr`.
(fmap f e)
Returns a [[Literal]] generated by applying f
to the expression part of
e
.
literal-type
and [[meta]] will return the same thing for e
and the
return value.
Returns a [[Literal]] generated by applying `f` to the expression part of `e`. [[literal-type]] and [[meta]] will return the same thing for `e` and the return value.
(literal-apply type op args)
Similar to make-literal
, but accepts:
Similar to clojure.core/apply
.
For example:
(literal-apply ::numeric 'cos [1 2 3])
;;=> (cos 1 2 3)
Similar to [[make-literal]], but accepts: - some operation - the arguments to which it applies Similar to `clojure.core/apply`. For example: ```clojure (literal-apply ::numeric 'cos [1 2 3]) ;;=> (cos 1 2 3) ```
(literal-type x)
If x
is a [[Literal]] instance, returns its type. Else, returns nil.
If `x` is a [[Literal]] instance, returns its type. Else, returns nil.
(literal? x)
Returns true if x
is a [[Literal]] instance, false otherwise.
Returns true if `x` is a [[Literal]] instance, false otherwise.
(make-literal type expr)
Constructs a [[Literal]] instance with the supplied type and an empty metadata
map out of the literal form expr
.
Constructs a [[Literal]] instance with the supplied type and an empty metadata map out of the literal form `expr`.
(substitute expr s-map)
(substitute expr old new)
Returns a form similar to expr
, with all instances of old
replaced by
new
. Substitution occurs
in postwalk order.
NOTE that this now works for expressions too.
Returns a form similar to `expr`, with all instances of `old` replaced by `new`. Substitution occurs in [postwalk](https://clojuredocs.org/clojure.walk/postwalk) order. NOTE that this now works for expressions too.
(variables-in expr)
Return the set of 'variables' (e.g. symbols) found in expr
.
expr
is either a symbol, a [[Literal]] instance or some sequence
representing a symbolic expression.
Return the set of 'variables' (e.g. symbols) found in `expr`. `expr` is either a symbol, a [[Literal]] instance or some sequence representing a symbolic expression.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close