From 8148e755d3f587e6c212ba90efc151ea07de2703 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 15 Dec 2012 00:15:35 +0000 Subject: Add Subst::augment function. git-svn-id: http://svn.drobilla.net/resp/trunk@438 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/resp.hpp | 1 + src/unify.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/resp.hpp b/src/resp.hpp index 8cdb75e..f4689a0 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -534,6 +534,7 @@ struct Subst : public list { if (s && t) { assert(s != t); push_back(Constraint(s, t)); } } static Subst compose(const Subst& delta, const Subst& gamma); + void augment(const Subst& subst); void add(const AST* from, const AST* to) { assert(from && to); push_back(Constraint(from, to)); diff --git a/src/unify.cpp b/src/unify.cpp index a7f7822..48ae1dd 100644 --- a/src/unify.cpp +++ b/src/unify.cpp @@ -85,6 +85,16 @@ substitute(const AST* in, const AST* from, const AST* to) return ret.head; } +void +Subst::augment(const Subst& subst) +{ + for (Subst::const_iterator s = subst.begin(); s != subst.end(); ++s) { + if (!contains(s->first)) { + add(s->first, s->second); + } + } +} + /// Compose two substitutions (TAPL 22.1.1) Subst Subst::compose(const Subst& delta, const Subst& gamma) -- cgit v1.2.1