Execute SNUSP: Difference between revisions

m
m (→‎{{header|Phix}}: added syntax colouring, marked p2js compatible)
(4 intermediate revisions by 4 users not shown)
Line 6:
=={{header|11l}}==
{{trans|Python}}
<langsyntaxhighlight lang="11l">V HW = ‘
/++++!/===========?\>++.>+.+++++++..+++\
\+++\ | /+>+++++++>/ /++++++++++<<.++>./
Line 48:
ds[dp] = Byte(:stdin.read(1).code)
‘/’
id = (-)~id
‘\’
id (+)= 1
Line 58:
step()
 
snusp(5, HW)</langsyntaxhighlight>
{{out}}
<pre>
Line 84:
=={{header|D}}==
See [[RCSNUSP/D]].
 
=={{header|EasyLang}}==
{{trans|Go}}
<syntaxhighlight>
proc snusp dlen raw$ . .
len ds[] dlen
is$[] = strsplit raw$ "\n"
for s$ in is$[]
is$[][] &= strchars s$
.
for ipr to len is$[][]
for ipc to len is$[ipr][]
if is$[ipr][ipc] = "$"
break 2
.
.
.
dp = 1
id = 0
#
subr step
if id mod 2 = 0
ipc += 1 - bitand id 2
else
ipr += 1 - bitand id 2
.
.
while ipr >= 1 and ipr <= len is$[][] and ipc >= 1 and ipc <= len is$[ipr][]
c$ = is$[ipr][ipc]
if c$ = ">"
dp += 1
elif c$ = "<"
dp -= 1
elif c$ = "+"
ds[dp] += 1
elif c$ = "-"
ds[dp] -= 1
elif c$ = "."
write strchar ds[dp]
elif c$ = ","
# ds[dp] = strcode input
elif c$ = "/"
id = bitxor id 3
elif c$ = "\\"
id = bitxor id 1
elif c$ = "!"
step
elif c$ = "?"
if ds[dp] = 0
step
.
.
step
.
.
s$ = input
while s$ <> ""
cod$ &= "\n" & s$
s$ = input
.
snusp 5 cod$
#
input_data
/++++!/===========?\>++.>+.+++++++..+++\
\+++\ | /+>+++++++>/ /++++++++++<<.++>./
$+++/ | \+++++++++>\ \+++++.>.+++.-----\
\==-<<<<+>+++/ /=.>.+>.--------.-/
 
</syntaxhighlight>
 
=={{header|F_Sharp|F#}}==
Line 98 ⟶ 167:
 
=={{header|Icon}} and {{header|Unicon}}==
<langsyntaxhighlight lang="icon">#
# snusp.icn, A Modular SNUSP interpreter
#
Line 284 ⟶ 353:
write()
}
end</langsyntaxhighlight>
 
{{out}}
Line 293 ⟶ 362:
=={{header|J}}==
This program places no limits on the program or data size. Perhaps I'll revisit and write a tacit version of the SNUSP interpreter.
<syntaxhighlight lang="j">
<lang J>
Note 'snusp'
 
Line 347 ⟶ 416:
end.
)
</syntaxhighlight>
</lang>
Store <langsyntaxhighlight SNUSPlang="snusp">\ display JJ and linefeed, then loop forever
\ +++++++++++++++++++++++++++++++++++++\
! /+++++++++++++++++++++++++++++++++++++/
/ \..<+++++\
\ . +++++/
</langsyntaxhighlight> as J.snusp
<pre>
load'snusp.ijs' NB. the j code above
Line 373 ⟶ 442:
=={{header|Julia}}==
This Modular SNUSP interpreter uses modular calls to echo the first 2 characters entered. Try typing "Hi" at the prompt.
<langsyntaxhighlight lang="julia">const echo2 = raw"""
/==!/======ECHO==,==.==#
| |
Line 427 ⟶ 496:
end
 
snusp(100, echo2)</langsyntaxhighlight> {{output}} <pre>
> Hi
Hi
Line 435 ⟶ 504:
=={{header|Kotlin}}==
{{trans|Go}}
<langsyntaxhighlight lang="scala">// version 1.1.2
 
// requires 5 chars (10 bytes) of data store
Line 497 ⟶ 566:
fun main(args: Array<String>) {
snusp(5, hw)
}</langsyntaxhighlight>
 
{{out}}
Line 512 ⟶ 581:
=={{header|Nim}}==
{{trans|Python}}
<langsyntaxhighlight Nimlang="nim">import strutils
 
# Requires 5 bytes of data store.
Line 571 ⟶ 640:
 
when isMainModule:
snusp(5, Hw)</langsyntaxhighlight>
 
{{out}}
Line 584 ⟶ 653:
=={{header|Phix}}==
{{trans|Go}}
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">id</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">ipr</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">ipc</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span>
Line 646 ⟶ 715:
<span style="color: #000000;">snusp</span><span style="color: #0000FF;">(</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">hw</span><span style="color: #0000FF;">)</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 657 ⟶ 726:
=={{header|Python}}==
{{trans|Go}}
<langsyntaxhighlight lang="python">#!/usr/bin/env python3
 
HW = r'''
Line 711 ⟶ 780:
 
if __name__ == '__main__':
snusp(5, HW)</langsyntaxhighlight>
{{out}}
<pre>
Line 724 ⟶ 793:
{{works with|Rakudo|2017.02}}
Implementation of modular SNUSP.
<syntaxhighlight lang="raku" perl6line>class SNUSP {
 
has @!inst-pointer;
Line 794 ⟶ 863:
 
my $snusp = SNUSP.new;
$snusp.run($hw)</langsyntaxhighlight>
{{out}}
<pre>Hello World!</pre>
Line 804 ⟶ 873:
The interpreter below implements Core SNUSP:
 
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
 
const proc: snusp (in string: sourceCode, in integer: memSize, inout file: input, inout file: output) is func
Line 864 ⟶ 933:
begin
snusp(helloWorld, 5, IN, OUT);
end func;</langsyntaxhighlight>
 
{{out}}
Line 876 ⟶ 945:
=={{header|Wren}}==
{{trans|Go}}
<langsyntaxhighlight ecmascriptlang="wren">import "io" for Stdin
 
// 'raw' is a multi-line string
Line 949 ⟶ 1,018:
"$+++/ | \\+++++++++>\\ \\+++++.>.+++.-----\\\n" +
" \\==-<<<<+>+++/ /=.>.+>.--------.-/"
snusp.call(5, hw)</langsyntaxhighlight>
 
{{out}}
2,046

edits