Liking cljdoc? Tell your friends :D

formform.expr

API for the expr module of formform.

API for the `expr` module of `formform`.
raw docstring

=>clj/s


=>*clj/s


>>clj/s


arrangement?clj/s


chain>>clj/s


defoperatorclj/smacro

(defoperator k args interpretation & params)

Defines a new operator by its symbol (a keyword), a vector of arguments and an interpretation function. Takes additional key-value pairs for options.

Registers various methods for the operator:

  • interpret-op to access the interpretation function
  • make-op -> constructor (either uses the provided args or a custom constructor function via the option :constructor)
  • simplify-op -> simplifier (either defaults to the given interpretation function or uses a custom reducer via the option :reducer)
  • valid-op? -> validator (provided by the :predicate option)
  • op-data -> returns a key-value map of the operator arguments
  • op-get -> returns a specific value by a given argument-key
Defines a new operator by its symbol (a keyword), a vector of arguments and an interpretation function. Takes additional key-value pairs for options.

Registers various methods for the operator: 

* `interpret-op` to access the interpretation function
* `make-op` -> constructor (either uses the provided `args` or a custom constructor function via the option `:constructor`)
* `simplify-op` -> simplifier (either defaults to the given interpretation function or uses a custom reducer via the option `:reducer`)
* `valid-op?` -> validator (provided by the `:predicate` option)
* `op-data` -> returns a key-value map of the operator arguments
* `op-get` -> returns a specific value by a given argument-key
raw docstring

defsymbolclj/smacro

(defsymbol k interpretation & params)

Defines a new expression symbol by its symbol (a keyword) and an interpretation function. Takes additional key-value pairs for options.

Registers various methods for the expression symbol:

  • interpret-sym -> to access the interpretation function
  • simplify-sym -> simplifier (either defaults to the given interpretation function or uses a custom reducer via the option :reducer)
Defines a new expression symbol by its symbol (a keyword) and an interpretation function. Takes additional key-value pairs for options.

Registers various methods for the expression symbol:

* `interpret-sym` -> to access the interpretation function
* `simplify-sym` -> simplifier (either defaults to the given interpretation function or uses a custom reducer via the option `:reducer`)
raw docstring

equalclj/s

(equal & exprs)

Equality check for expressions. Two expressions are considered equal, if their formDNAs are equal. Compares formDNAs from evaluation results of each expression by calling calc/equal-dna.

  • ordering of variable names in formDNA matters, see find-vars
  • stricter than equiv, which compares by calc/equiv-dna
Equality check for expressions. Two expressions are considered equal, if their formDNAs are equal. Compares formDNAs from evaluation results of each expression by calling `calc/equal-dna`.

* ordering of variable names in formDNA matters, see `find-vars`
* stricter than `equiv`, which compares by `calc/equiv-dna`
raw docstring

equivclj/s

(equiv & exprs)

Equivalence check for expressions. Two expressions are considered equivalent, if their formDNAs are equivalent. Compares formDNAs from evaluation results of each expression by calling calc/equiv-dna.

  • ordering of variable names in formDNA is irrelevant
  • looser than equal, which compares by calc/equal-dna
  • can be slow on expressions with 6+ variables
Equivalence check for expressions. Two expressions are considered equivalent, if their formDNAs are equivalent. Compares formDNAs from evaluation results of each expression by calling `calc/equiv-dna`.

* ordering of variable names in formDNA is irrelevant
* looser than `equal`, which compares by `calc/equal-dna`
* can be slow on expressions with 6+ variables
raw docstring

eval->exprclj/s

(eval->expr expr)
(eval->expr expr env)

Evaluates a FORM expression with an optional env and returns a constant expression with attached metadata including the maximally reduced expression in :expr and the environment in :env.

  • env must be a map with a content/variable in expr as a key
Evaluates a FORM expression with an optional `env` and returns a constant expression with attached metadata including the maximally reduced expression in `:expr` and the environment in `:env`.

* `env` must be a map with a content/variable in `expr` as a key
raw docstring

eval->expr-allclj/s

(eval->expr-all expr)
(eval->expr-all expr env)
(eval->expr-all opts expr env)

Evaluates a FORM expression for all possible interpretations of any occurring variable in the expression. Returns a formDNA expression by default.

  • if to-fdna? is false, returns a seq of results as returned by => in the order of the corresponding vspace ordering
Evaluates a FORM expression for all possible interpretations of any occurring variable in the expression. Returns a formDNA expression by default.

* if `to-fdna?` is false, returns a seq of results as returned by `=>` in the order of the corresponding `vspace` ordering
raw docstring

eval-allclj/s

(eval-all expr)
(eval-all expr env)
(eval-all opts expr env)

Evaluates a FORM expresson for all possible interpretations of any occurring variable in the expresson. Returns a map with a :results key whose value is a sequence of [<interpretation> <result>] tuples and with a :varorder key whose value is the reading order for variable results in the interpretations. This output is particularly suited for value tables.

Evaluates a FORM expresson for all possible interpretations of any occurring variable in the expresson. Returns a map with a `:results` key whose value is a sequence of `[<interpretation> <result>]` tuples and with a `:varorder` key whose value is the reading order for variable results in the interpretations. This output is particularly suited for value tables.
raw docstring

evaluateclj/s

(evaluate expr)
(evaluate expr env)

Evaluates a FORM expresson with an optional env and returns either a constant or the simplified expression if it could not be determined to a value.

Evaluates a FORM expresson with an optional `env` and returns either a constant or the simplified expression if it could not be determined to a value.
raw docstring

expr->constclj/s

(expr->const expr)

Given an expression, returns the corresponding constant value.

Given an expression, returns the corresponding constant value.
raw docstring

expr-symbol?clj/s


expression?clj/s


find-subexprsclj/s

(find-subexprs expr subexprs)

Finds all subexpressions in expr that match any element of the given set subexprs.

Finds all subexpressions in `expr` that match any element of the given set `subexprs`.
raw docstring

find-varsclj/s

(find-vars expr opts)

Finds all variables in an expresson or returns the expression itself if it is a variable.

Options:

  • {:ordered true} to return variables in: type order -> alphanumeric order
  • {:vars #{…}} can be given a set of specific variables to find
Finds all variables in an expresson or returns the expression itself if it is a variable.

Options:

* {:ordered true} to return variables in: type order -> alphanumeric order
* {:vars #{…}} can be given a set of specific variables to find
raw docstring

formclj/s

(form & args)

Constructor for FORM expressions. Calls make on arguments.

Constructor for FORM expressions. Calls `make` on arguments.
raw docstring

form?clj/s


formDNA?clj/s


gen-varsclj/s

(gen-vars n)

Generates a number of variables with random names.

Generates a number of variables with random names.
raw docstring

in>>clj/s


interpretclj/s

(interpret expr)
(interpret env expr)

Interprets an expression of any kind. Returns the original expression if it cannot be interpreted.

Can be given an env map to interpret variables (as keys). This map can have an optional --defocus entry whose value is a set of items that should not be interpreted and a complementary --focus entry to only interpret the items specified in its set and nothing else.

  • the keywords :ops / :syms / :vars designate all operations / expression symbols / variables
  • an operator symbol can provided to designate a specific operator
  • any other expression (like a variable) can be designated as itself
  • --focus and --defocus can cancel each other out if they contain the same item so you usually pick one or the other
Interprets an expression of any kind. Returns the original expression if it cannot be interpreted.

Can be given an `env` map to interpret variables (as keys). This map can have an optional `--defocus` entry whose value is a set of items that should not be interpreted and a complementary `--focus` entry to only interpret the items specified in its set and nothing else.

* the keywords `:ops` / `:syms` / `:vars` designate _all_ operations / expression symbols / variables
* an operator symbol can provided to designate a specific operator
* any other expression (like a variable) can be designated as itself
* `--focus` and `--defocus` can cancel each other out if they contain the same item so you usually pick one or the other
raw docstring

interpret*clj/s

(interpret* expr)
(interpret* env expr)

Like interpret, but repeats substitution on interpreted expressions until they cannot be interpreted any further.

Like `interpret`, but repeats substitution on interpreted expressions until they cannot be interpreted any further.
raw docstring

interpret-opclj/smultimethod

Interprets a symbolic expression with a registered operator.

Note: default to use interpret instead

Interprets a symbolic expression with a registered operator.

Note: default to use `interpret` instead
raw docstring

interpret-symclj/smultimethod

Interprets a registered symbol.

Note: default to use interpret instead

Interprets a registered symbol.

Note: default to use `interpret` instead
raw docstring

interpret-walkclj/s

(interpret-walk expr)
(interpret-walk env expr)

Recursively calls interpret on given expression and all its subexpressions with a depth-first walk.

Recursively calls `interpret` on given expression and all its subexpressions with a depth-first walk.
raw docstring

interpret-walk*clj/s

(interpret-walk* expr)
(interpret-walk* env expr)

Like interpret-walk, but repeats substitution on interpreted (sub-)expressions until they cannot be interpreted any further.

Like `interpret-walk`, but repeats substitution on interpreted (sub-)expressions until they cannot be interpreted any further.
raw docstring

isolatorclj/s

(isolator c)

Given a constant, returns the corresponding FORM from the isolator class.

Given a constant, returns the corresponding FORM from the isolator class.
raw docstring

makeclj/s

(make & args)

Constructor for expressions of any kind. Validates its input. If the first argument (or the first after the options map) is a keyword of a registered operator, will call the constructor for that operator

Can be given an options map as first argument:

  • mark? (default: false) marks the whole expression, creating a FORM
  • splice? (default: true) dissolves all top-level arrangements
Constructor for expressions of any kind. Validates its input. If the first argument (or the first after the options map) is a keyword of a registered operator, will call the constructor for that operator

Can be given an options map as first argument:

* `mark?` (default: false) marks the whole expression, creating a FORM
* `splice?` (default: true) dissolves all top-level arrangements
raw docstring

make-opclj/smultimethod

Constructs a symbolic expression given a registered operator and parameters.

Note: default to use make instead of make-op

Constructs a symbolic expression given a registered operator and parameters.

Note: default to use `make` instead of `make-op`
raw docstring

mark-exprsclj/s

(mark-exprs opts & exprs)

Chains expressions like ((a)(b)…) or (a)(b)… if {:unmarked? true}`

  • group expressions with arrangements: [:- x y …]
Chains expressions like `((a)(b)…)` or `(a)(b)…` if {:unmarked? true}`

* group expressions with arrangements: `[:- x y …]`
raw docstring

memoryclj/s

(memory rem-pairs & exprs)

Constructs a memory FORM from a given list of rem-pairs (key-value pairs, where both the key and the value is an expression) and one or more expressions which are in their scope.

Constructs a memory FORM from a given list of `rem-pair`s (key-value pairs, where both the key and the value is an expression) and one or more expressions which are in their scope.
raw docstring

memory-extendclj/s

(memory-extend mem & ext-pairs)

Takes a memory FORM and extends its rem-pairs by one or more given extension pairs.

Takes a memory FORM and extends its `rem-pair`s by one or more given extension pairs.
raw docstring

memory-replaceclj/s

(memory-replace mem & repl-pairs)

Takes a memory FORM and replaces its rem-pairs by one or more given replacement pairs.

Takes a memory FORM and replaces its `rem-pair`s by one or more given replacement pairs.
raw docstring

memory?clj/s


nest-exprsclj/s

(nest-exprs opts & exprs)

Nests expressions leftwards (((…)a)b) or rightwards (a(b(…))) if {:ltr? true}

  • use nil for empty expressions
  • use an arrangement (make x y …) to add multiple exprs. to the same level
Nests expressions leftwards `(((…)a)b)` or rightwards `(a(b(…)))` if `{:ltr? true}`

* use `nil` for empty expressions
* use an arrangement `(make x y …)` to add multiple exprs. to the same level
raw docstring

op-dataclj/smultimethod

Gets all parameters from a symbolic expression with a registered operator as a map.

Gets all parameters from a symbolic expression with a registered operator as a map.
raw docstring

op-getclj/smultimethod

Gets a specified part from a symbolic expression with a registered operator.

Gets a specified part from a symbolic expression with a registered operator.
raw docstring

op-symbolclj/s

Returns the symbol of a given operator.

Returns the symbol of a given operator.
raw docstring

op-symbol?clj/s


operator?clj/s


rem-pair?clj/s


selectorclj/s

(selector vars->consts)
(selector vars->consts simplify?)

Given a map variable->constant, returns a FORM from the selector class.

Given a map variable->constant, returns a FORM from the selector class.
raw docstring

seq-reclj/s

(seq-re specs & nested-exprs)

Constructs a self-equivalent re-entry FORM given the arguments:

  • specs: either a seq-reentry-signature or an options map
  • nested-exprs: zero or more expressions intended as a nested sequence
Constructs a self-equivalent re-entry FORM given the arguments:

* `specs`: either a `seq-reentry-signature` or an options map
* `nested-exprs`: zero or more expressions intended as a nested sequence
raw docstring

seq-reentry-opts->signclj/s

(seq-reentry-opts->sign opt-map)

Inverse map of seq-reentry-sign->opts with default args.

Inverse map of seq-reentry-sign->opts with default args.
raw docstring

seq-reentry-opts?clj/s


seq-reentry-sign->optsclj/s

(seq-reentry-sign->opts sign)

Maps signatures for self-equivalent re-entry FORMs to their corresponding option-maps.

Maps signatures for self-equivalent re-entry FORMs to their corresponding option-maps.
raw docstring

seq-reentry-signature?clj/s


seq-reentry?clj/s


simplifyclj/s

(simplify x)
(simplify x env)

Simplifies a FORM recursively until it cannot be further simplified. All deductions are justified by the axioms of FORM logic.

  • if x is a complex FORM, calls simplify-context on x
  • if no simplification applies, tries to retrieve the value from given env
  • if retrieval was unsuccessful, returns x as is
Simplifies a FORM recursively until it cannot be further simplified. All deductions are justified by the axioms of FORM logic.

* if `x` is a complex FORM, calls `simplify-context` on `x`
* if no simplification applies, tries to retrieve the value from given `env`
* if retrieval was unsuccessful, returns `x` as is
raw docstring

simplify-expr-chainclj/s

(simplify-expr-chain chain env)
(simplify-expr-chain opts chain env)

Reduces a sequence of expressions, intended to be linked in a chain, to a sequence of simplified expressions, possibly spliced or shortened via inference.

  • assumes rightward-nesting, e.g. (…(…(…)))
  • for leftward-nesting, e.g. (((…)…)…), pass {:rtl? true}
Reduces a sequence of expressions, intended to be linked in a `chain`, to a sequence of simplified expressions, possibly spliced or shortened via inference.

* assumes rightward-nesting, e.g. `(…(…(…)))`
* for leftward-nesting, e.g. `(((…)…)…)`, pass `{:rtl? true}`
raw docstring

simplify-inclj/s

(simplify-in ctx)
(simplify-in ctx env)

Simplifies a context/sequence of FORMs recursively until it cannot be further simplified. All deductions are justified by the axioms of FORM logic.

  • for complex expressions, calls expr.core/simplify-content on every unique element
Simplifies a context/sequence of FORMs recursively until it cannot be further simplified. All deductions are justified by the axioms of FORM logic.

* for complex expressions, calls `expr.core/simplify-content` on every unique element
raw docstring

simplify-opclj/smultimethod

Simplifies a symbolic expression with a registered operator given an optional environment.

Note: default to use simplify instead

Simplifies a symbolic expression with a registered operator given an optional environment.

Note: default to use `simplify` instead
raw docstring

simplify-symclj/smultimethod

Simplifies a registered symbol given an optional environment.

Note: default to use simplify instead

Simplifies a registered symbol given an optional environment.

Note: default to use `simplify` instead
raw docstring

unclear?clj/s


valid-op?clj/smultimethod

Validates the shape of a symbolic expression with a registered operator.

Validates the shape of a symbolic expression with a registered operator.
raw docstring

variable?clj/s

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

× close