Jump to content

Execute SNUSP: Difference between revisions

Added 11l
(Added 11l)
Line 3:
 
An implementation need only properly implement the Core SNUSP instructions <nowiki>('$', '\', '/', '+', '-', '<', '>', ',', '.', '!', and '?')</nowiki>. Modular SNUSP ('#', '@') and Bloated SNUSP (':', ';', '%', and '&') are also allowed, but not required. Any extra characters that you implement should be noted in the description of your implementation. Any cell size is allowed, EOF support is optional, as is whether you have bounded or unbounded memory.
 
=={{header|11l}}==
{{trans|Python}}
<lang 11l>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)</lang>
{{out}}
<pre>
Hello World!
</pre>
 
=={{header|Ada}}==
1,481

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.