Execute SNUSP: Difference between revisions

Content added Content deleted
Line 117: Line 117:
$==>==@/==@/==<==#"""
$==>==@/==@/==<==#"""


@enum Direction dleft dup dright ddown
@enum Direction left up right down


function snusp(datalength, progstring)
function snusp(datalength, progstring)
Line 123: Line 123:
data = zeros(datalength)
data = zeros(datalength)
dp = ipx = ipy = 1
dp = ipx = ipy = 1
direction = dright # default to go to right at beginning
direction = right # default to go to right at beginning


lines = split(progstring, "\n")
lines = split(progstring, "\n")
Line 148: Line 148:
inboundsy(plus) = (plus ? (ipy < length(lines)) : (ipy > 1)) ? true : exit(data[dp])
inboundsy(plus) = (plus ? (ipy < length(lines)) : (ipy > 1)) ? true : exit(data[dp])
function ipnext()
function ipnext()
if direction == dright && inboundsx(true) ipx += 1
if direction == right && inboundsx(true) ipx += 1
elseif direction == dleft && inboundsx(false) ipx -= 1
elseif direction == left && inboundsx(false) ipx -= 1
elseif direction == ddown && inboundsy(true) ipy += 1
elseif direction == down && inboundsy(true) ipy += 1
elseif direction == dup && inboundsy(false) ipy -= 1
elseif direction == up && inboundsy(false) ipy -= 1
end
end
end
end