Unify
Posted: Mon Oct 27, 2008 9:03 am
In my last blogpost I used built in function "unify". Unify tends to become bottleneck, and implementation is not trivial, so keeping it in the core language has alot of sense and it is advantage over CL and Scheme. Example:
If Y is replaced with ((a b) 3), X with (a b) and (Z with z) then these two lists are equal.
Unification makes a difference between "variable" and "constant" symbols. In existing version "variable" symbols start with uppercase. I have low priority proposal for additional version with explicit list of "variable" symbols:
Unify1 because unify as it is has its place and it might be better to keep many non-polymorphic alternatives like unify1, unify2, ... unify78 than to search for a "real thing". Low priority because although it is nice feature, it is still minor issue and not many Newlisp users have strong interest. So, v11 or v10.5 would be good enough.
Code: Select all
> (unify '(X (a b) z) '(Y X Z))
((Y (a b)) (X (a b)) (Z z))
Unification makes a difference between "variable" and "constant" symbols. In existing version "variable" symbols start with uppercase. I have low priority proposal for additional version with explicit list of "variable" symbols:
Code: Select all
(unify1 '(X (a b) z) '(Y X Z) '() '(X Y Z)) ; third parameter is already used