Execute SNUSP: Difference between revisions
Content added Content deleted
Line 117: | Line 117: | ||
$==>==@/==@/==<==#""" |
$==>==@/==@/==<==#""" |
||
@enum Direction |
@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 = |
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 == |
if direction == right && inboundsx(true) ipx += 1 |
||
elseif direction == |
elseif direction == left && inboundsx(false) ipx -= 1 |
||
elseif direction == |
elseif direction == down && inboundsy(true) ipy += 1 |
||
elseif direction == |
elseif direction == up && inboundsy(false) ipy -= 1 |
||
end |
end |
||
end |
end |