From 83e2c574bdefe2d040cdfbe20a73380a0f0123dd Mon Sep 17 00:00:00 2001 From: Carlo Zancanaro Date: Fri, 30 Mar 2012 18:09:10 +1100 Subject: Initial commit. Basic Kleene iteration stuff. --- Max.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Max.h (limited to 'Max.h') diff --git a/Max.h b/Max.h new file mode 100644 index 0000000..b3b5d65 --- /dev/null +++ b/Max.h @@ -0,0 +1,22 @@ +#ifndef MAX_H +#define MAX_H + +#include "Expression.h" + +template +struct Max : public Expression { + Max(Expression* left, Expression* right) + : _left(left), _right(right) { } + + T eval(const std::map& mappings) const { + T left = _left->eval(mappings); + T right = _right->eval(mappings); + return left < right ? right : left; + } + + private: + Expression* _left; + Expression* _right; +}; + +#endif -- cgit v1.2.3