Liking cljdoc? Tell your friends :D

dag_unify.core


assoc-inclj/s

(assoc-in m path v)

Similar to clojure.core/assoc-in, but uses unification so that existing values are unified rather than overwritten.

Similar to clojure.core/assoc-in, but uses unification so that existing values are unified rather than overwritten.
sourceraw docstring

assoc-in!clj/s

(assoc-in! m path v)

Similar to assoc-in, but m's references (if any) are modified.

Similar to assoc-in, but m's references (if any) are modified.
sourceraw docstring

copyclj/s

(copy input)
source

copy-with-bindingclj/s

(copy-with-binding input)
source

diagnostics?clj/s

If true:

  • copies input arguments to unify! to enable tracing where fails happen with unify.
  • concat a path along to recursive calls between unify! and unify-dags to enable debugging.
If true:
- copies input arguments to unify! to enable tracing where fails happen with unify.
- concat a path along to recursive calls between unify! and unify-dags to enable debugging.
sourceraw docstring

exception-if-cycle?clj/s

If true, and if unifying two DAGs would cause a cycle, thrown an exception. If false, return :fail rather than throwing an exception.

If true, and if unifying two DAGs would cause a cycle, thrown an exception. If false,
return :fail rather than throwing an exception.
sourceraw docstring

fail?clj/s

(fail? arg)
source

get-inclj/s

(get-in in-map path & [not-found])

same as clojure.core (get-in), but references are resolved and followed.

same as clojure.core (get-in), but references are resolved and followed.
sourceraw docstring

old2newclj/s

source

pathsclj/s

(paths d & [prefix])

return all paths found in dag d.

return all paths found in dag _d_.
sourceraw docstring

pprintclj/s

(pprint input)
source

pprint-with-bindingclj/s

(pprint-with-binding input)
source

ref-counterclj/s

source

ref2counter-valueclj/s

source

ref?clj/s

(ref? val)
source

resolve-refclj/s

(resolve-ref arg)

if arg is not a ref, return arg. if is a ref, return (resolve @arg)

if arg is not a ref, return arg. if is a ref, return (resolve @arg)
sourceraw docstring

subsumes?clj/s

(subsumes? a b)

Returns true if dag a is more general than dag b, or more precisely, dag a subsumes dag b if: for all p in paths(a), (unify (get-in a p) (get-in b p :fail)) is not fail.

For example, (subsumes? {:a 42} {:a 42, :b 43}) => true but: (subsumes? {:a 42, :b 43} {:a 42}) => false.

Returns true if dag _a_ is more general than dag _b_, 
or more precisely, dag _a_ subsumes dag _b_ if:
   for all _p_ in paths(a), (unify (get-in a _p_) (get-in b _p_ :fail)) is not fail.

For example, (subsumes? {:a 42} {:a 42, :b 43}) => true
        but: (subsumes? {:a 42, :b 43} {:a 42}) => false.
sourceraw docstring

unifyclj/s

(unify val1 val2)

like unify!, but non-destructively copy each argument before unifying.

like unify!, but non-destructively copy each argument before unifying.
sourceraw docstring

unify!clj/s

(unify! val1 val2 & [containing-refs path])

Merge input arguments val1 and val2, according to their types:

  • If val1 and val2 are maps, merge recursively (via unify-dags).
  • If val1 and/or val2 are references (Atoms), the references(s) will be updated to point to the unification of the resolved reference(s).
  • If val1 and/or val2 are atomic values (e.g. strings, numbers, etc), the unification is their equal value if they are equal, according to =, or :fail if they are not equal according to =.
Merge input arguments val1 and val2, according to their types:
- If val1 and val2 are maps, merge recursively (via unify-dags).
- If val1 and/or val2 are references (Atoms), the references(s) will
  be updated to point to the unification of the resolved reference(s).
- If val1 and/or val2 are atomic values (e.g. strings, numbers, etc),
  the unification is their equal value if they are equal, according
  to =, or :fail if they are not equal according to =.
sourceraw docstring

unify-dagsclj/s

(unify-dags dag1 dag2 containing-refs path)

Unify two maps into a single map (or :fail) by taking the union of their keys and for each :k in this union, unify the two values of :k, and use that unified value as the :k of the returned map.

  • If the unified value for :k is :fail, then return :fail for the whole function call.

  • If a cycle is detected during unification, for example, if dag1 is: {:a [[1] :top] :c [[1]]}}

    and dag2 is:

    {:a {:b [[2] :top] :c [[2]]}},

    then this function will return :fail if the dynamic variable exception-if-cycle? (declared above) is false. However, if exception-if-cycle? is set to true, this function will throw an exception. See core_test.clj/prevent-cyclic-graph-* functions for example usage.

Unify two maps into a single map (or :fail) by taking the union of their keys and for each
:k in this union, unify the two values of :k, and use that unified
value as the :k of the returned map.
- If the unified value for :k is :fail, then
return :fail for the whole function call.
- If a cycle is detected during unification, for example, if dag1 is:
  {:a [[1] :top]
   :c [[1]]}}

   and dag2 is:

  {:a {:b [[2] :top]
   :c [[2]]}},

  then this function will return :fail if the dynamic variable exception-if-cycle?
  (declared above) is false.
  However, if exception-if-cycle? is set to true, this function will throw an
  exception. See core_test.clj/prevent-cyclic-graph-* functions for example usage.
sourceraw docstring

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

× close