53 lines
1 KiB
Text
53 lines
1 KiB
Text
V HW = ‘
|
||
/++++!/===========?\>++.>+.+++++++..+++\
|
||
\+++\ | /+>+++++++>/ /++++++++++<<.++>./
|
||
$+++/ | \+++++++++>\ \+++++.>.+++.-----\
|
||
\==-<<<<+>+++/ /=.>.+>.--------.-/’
|
||
|
||
F snusp(store, code)
|
||
V ds = [Byte(0)] * store
|
||
V dp = 0
|
||
V cs = code.split("\n")
|
||
V ipr = 0
|
||
V ipc = 0
|
||
|
||
L(row) cs
|
||
ipc = row.findi(‘$’)
|
||
I ipc != -1
|
||
ipr = L.index
|
||
L.break
|
||
|
||
V id = 0
|
||
|
||
F step()
|
||
I @id [&] 1
|
||
@ipr += 1 - (@id [&] 2)
|
||
E
|
||
@ipc += 1 - (@id [&] 2)
|
||
|
||
L ipr >= 0 & ipr < cs.len & ipc >= 0 & ipc < cs[ipr].len
|
||
S cs[ipr][ipc]
|
||
‘>’
|
||
dp++
|
||
‘<’
|
||
dp--
|
||
‘+’
|
||
ds[dp]++
|
||
‘-’
|
||
ds[dp]--
|
||
‘.’
|
||
:stdout.write(Char(code' ds[dp]))
|
||
‘,’
|
||
ds[dp] = Byte(:stdin.read(1).code)
|
||
‘/’
|
||
id = ~id
|
||
‘\’
|
||
id (+)= 1
|
||
‘!’
|
||
step()
|
||
‘?’
|
||
I !(ds[dp])
|
||
step()
|
||
step()
|
||
|
||
snusp(5, HW)
|