diff --git a/poincare/src/simplification/Makefile b/poincare/src/simplification/Makefile index 04a34867a..cb50a87f1 100644 --- a/poincare/src/simplification/Makefile +++ b/poincare/src/simplification/Makefile @@ -15,6 +15,7 @@ products += $(rulesets) objs += $(addprefix $(prefix)/,\ expression_simplify.o \ rule.o \ + selector/any_selector.o \ selector/combination.o \ selector/selector.o \ selector/type_and_identifier_selector.o \ diff --git a/poincare/src/simplification/selector/any_selector.cpp b/poincare/src/simplification/selector/any_selector.cpp new file mode 100644 index 000000000..420d7a209 --- /dev/null +++ b/poincare/src/simplification/selector/any_selector.cpp @@ -0,0 +1,18 @@ +#include "any_selector.h" +#include "combination.h" + +namespace Poincare { +namespace Simplification { + +bool AnySelector::acceptsLocationInCombination(const Combination * combination, int location) const { + // Yes, if no other slot in the combination before me is the same + for (int i=0; iexpressionIndexForSelectorIndex(i) == combination->expressionIndexForSelectorIndex(location)) { + return false; + } + } + return immediateMatch(combination->expressionForSelectorIndex(location)); +} + +} +} diff --git a/poincare/src/simplification/selector/any_selector.h b/poincare/src/simplification/selector/any_selector.h index b39abec22..2efe39429 100644 --- a/poincare/src/simplification/selector/any_selector.h +++ b/poincare/src/simplification/selector/any_selector.h @@ -9,9 +9,7 @@ namespace Simplification { class AnySelector : public Selector { public: using Selector::Selector; - bool acceptsLocationInCombination(const Combination * combination, int location) const override { - return true; - } + bool acceptsLocationInCombination(const Combination * combination, int location) const override; bool immediateMatch(const Expression * e) const override { return true; }