dad9b0f816
Some weeks ago, anonymous functions as expressions were added to PascaLIGO, unfortunately in a manner that allowed in theory for contexts in which a named function was found when an anonymous was expected, and vice-versa. That explains that the simplifier had two new possible errors: * unexpected_anonymous_function ("you provided a function declaration without name") * unexpected_named_function I changed the AST and the parser so that function expressions correspond to anonymous functions (without block) and function declarations correspond to named functions. I also removed a error in the simplifier, which was unused: * bad_bytes ("you provided a function expression with a name (remove it)") |
||
---|---|---|
.. | ||
.links | ||
.PartitionMain.tag | ||
build.sh | ||
clean.sh | ||
dune | ||
dune-project | ||
LICENSE | ||
Makefile.cfg | ||
Partition0.ml | ||
Partition1.ml | ||
Partition2.ml | ||
Partition3.ml | ||
Partition.mli | ||
PartitionMain.ml | ||
README.md | ||
UnionFind.install | ||
unionFind.ml | ||
UnionFind.opam |
Some implementations in OCaml of the Union/Find algorithm
All modules implementing Union/Find can be coerced by the same
signature Partition.S
.
Note the function alias
which is equivalent to equiv
, but not
symmetric: alias x y
means that x
is an alias of y
, which
translates in the present context as x
not being the representative
of the equivalence class containing the equivalence between x
and
y
. The function alias
is useful when managing aliases during the
static analyses of programming languages, so the representatives of
the classes are always the original object.
The module PartitionMain
tests each with the same equivalence
relations.
Partition0.ml
This is a naive, persistent implementation of Union/Find featuring an asymptotic worst case cost of O(n^2).
Partition1.ml
This is a persistent implementation of Union/Find with height-balanced forests and without path compression, featuring an asymptotic worst case cost of O(n*log(n)).
Partition2.ml
This is an alternate version of Partition1.ml
, using a different
data type.
Partition3.ml
This is a destructive implementation of Union/Find with height-balanced forests but without path compression, featuring an asymptotic worst case of O(n*log(n)). In practice, though, this implementation should be faster than the previous ones, due to a smaller multiplicative constant term.