From 8b02cc65072b8c6b189b104926ff5a3767e3722b Mon Sep 17 00:00:00 2001 From: jantuomi Date: Thu, 1 Sep 2016 15:02:21 +0300 Subject: Add splice --- src/runtime.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/runtime.cpp') diff --git a/src/runtime.cpp b/src/runtime.cpp index 7519ea9..d4c9154 100644 --- a/src/runtime.cpp +++ b/src/runtime.cpp @@ -22,6 +22,9 @@ void Runtime::runCommand(const Token& token) { else if (lexeme == "O") { doPrintAscii(); } + else if (lexeme == ":") { + doSplice(); + } } void Runtime::run(std::vector& tokens) { @@ -52,3 +55,11 @@ void Runtime::doSum() { m_values.push_back(sum); } + +void Runtime::doSplice() { + int count = m_values.back(); + m_values.pop_back(); + + std::vector spliced(m_values.begin(), m_values.begin() + count); + m_values = spliced; +} -- cgit v1.3