Increment

From Esolang
Jump to: navigation, search

Increment

Commands

Character What it does
Any character except the ones listed below Increment the accumulator by the character's ASCII value.
& Print the accumulator, and end the program.
[ Turn off the user's computer.

Examples

Discover the answer to life, the universe, and everything

*&

Partial Implementation

function Increment(str)
	local acc = 0
	for char in str:gmatch(".") do
		if char == "&" then
			print(acc)
			return
		elseif char == "[" then
			print("Error: command unimplemented.")
			return
		else
			acc = acc + string.byte(char)
		end
	end
end