Module:Esoteric

local main={} local loop="([{}])" local func={ ["i"] = input, ["o"] = output, ["I"] = input(1), ["O"] = output(1), ["0"] = popstack(0), ["1"] = popstack(1), ["d"] = duplicate, ["D"] = delete, ["+"] = add, ["-"] = add(nil,1), ["'"] = add(1), ["\""]= add(1,1), ["p"] = move(1), ["q"] = move(-1), ["r"] = reverse, ["s"] = swap,} --oIO01dD+-'\"pqrs([E"

local stack="" local input="" local output="" --stack functions-- ---modify--- function add (x,y) stack=(string.sub(stack,1,1)) end ---movement--- function move (x) stack=(x>0) and sub(stack,x+1,-1)..sub(stack,1,x) or sub(stack,x,-1)..sub(stack,1,x-1) end function swap stack=sub(stack,2,2)..sub(stack,1,1)..sub(stack,3,-1) end function reverse stack=string.reverse(stack) end --ios-- function input (x) i,input=sub(input,1,1),sub(input,2,-1) popstack(x and string.byte(i) or tonumber(i) or 0) end

function output (x) s,stack=sub(stack,1,1),sub(stack,2,-1) output=output .. (x and string.byte(i) or i) end

--main function-- function run (a,x) input=x while i<#a do i=i+func[sub(a,i,i)] end return output end

function main.strip (frame) output=run(frame.args[1],frame.args[2]) return output end return main