From d95a42c7b299e43bfe026c0a2e8233679ccfc01c Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Thu, 10 Sep 2015 15:38:09 +0200 Subject: add mkarrayp --- functions.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'functions.cpp') diff --git a/functions.cpp b/functions.cpp index dacd194..03b8805 100644 --- a/functions.cpp +++ b/functions.cpp @@ -394,6 +394,20 @@ unordered_map&,unordered_map())); }}, + //mkarray prefill + {"mkarrayp",[](vector &S,unordered_map &variables){ + BUILTIN_GUARD_STACKSIZE("mkarrayp",1) + const Stackitem nitems=move(S.back()); S.pop_back(); + if(nitems.type!=SIT_INT)throw string("Argument to 'mkarrayp' not a number"); + if(nitems.intval<0)throw string("Negative argument to 'mkarrayp'"); + BUILTIN_GUARD_STACKSIZE("mkarrayp: prefill",nitems.intval); + Stackitem res((vector())); + res.arrval.reserve(nitems.intval); + const int sz=S.size(); + for(int i=sz-nitems.intval;i &S,unordered_map &variables){ BUILTIN_GUARD_STACKSIZE("arridx",2) -- cgit v1.2.3-70-g09d2