Execute SNUSP: Difference between revisions

m
Line 134:
end
 
right()instruction = Dict([('>', ()->dp += 1),
left ('<', () =-> (dp -= 1; if dp < 0 running = false end)), ('+', ()-> data[dp] += 1),
incr ('-', ()-> data[dp] -= 1), (',', ()-> (data[dp] += 1read(stdin, UInt8))),
decr() = ('.', ()->print(Char(data[dp] -= 1))),
lurd ()'/', =()-> (d = Int(direction); d += (iseven(d) ? 13 : -15); direction = Direction(d % 4))),
readsn() = (data[dp] = read(stdin, UInt8))
('\\', ()-> (d = Int(direction); d += (iseven(d) ? 1 : -1); direction = Direction(d))),
writesn() = print(Char(data[dp]))
ruld() = (d = Int(direction'!', (); d +=-> ipnext(iseven(d)), ('?', 3()-> :if 5); directiondata[dp] == 0 Directionipnext(d) % 4)end),
enter() = ('@', ()-> push!(stack, (ipx, ipy, direction))),
lurd() = (d = Int(direction); d += (iseven(d) ? 1 : -1); direction = Direction(d))
leave() = ('#', ()-> if length(stack) > 0 (ipx, ipy, direction) = pop!(stack) end),
skip() = ipnext()
stop ('\n', () =-> (running = false))])
skipifz() = if data[dp] == 0 ipnext() end
enter() = (push!(stack, (ipx, ipy, direction)))
leave() = (if length(stack) > 0 (ipx, ipy, direction) = pop!(stack) end)
stop() = (running = false)
instruction = Dict([('>',right), ('<',left), ('+',incr), ('-',decr),
(',',readsn), ('.',writesn), ('/',ruld), ('\\',lurd), ('!',skip),
('?',skipifz), ('@',enter), ('#',leave), ('\n',stop)])
 
inboundsx(plus) = (plus ? (ipx < lmax) : (ipx > 1)) ? true : exit(data[dp])
Line 177 ⟶ 171:
>
</pre>
 
 
=={{header|Kotlin}}==
4,102

edits