Execute SNUSP: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added syntax colouring, marked p2js compatible) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 6: | Line 6: | ||
=={{header|11l}}== |
=={{header|11l}}== |
||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">V HW = ‘ |
||
/++++!/===========?\>++.>+.+++++++..+++\ |
/++++!/===========?\>++.>+.+++++++..+++\ |
||
\+++\ | /+>+++++++>/ /++++++++++<<.++>./ |
\+++\ | /+>+++++++>/ /++++++++++<<.++>./ |
||
Line 58: | Line 58: | ||
step() |
step() |
||
snusp(5, HW)</ |
snusp(5, HW)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 98: | Line 98: | ||
=={{header|Icon}} and {{header|Unicon}}== |
=={{header|Icon}} and {{header|Unicon}}== |
||
< |
<syntaxhighlight lang="icon"># |
||
# snusp.icn, A Modular SNUSP interpreter |
# snusp.icn, A Modular SNUSP interpreter |
||
# |
# |
||
Line 284: | Line 284: | ||
write() |
write() |
||
} |
} |
||
end</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 293: | Line 293: | ||
=={{header|J}}== |
=={{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. |
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' |
Note 'snusp' |
||
Line 347: | Line 347: | ||
end. |
end. |
||
) |
) |
||
</syntaxhighlight> |
|||
</lang> |
|||
Store < |
Store <syntaxhighlight lang="snusp">\ display JJ and linefeed, then loop forever |
||
\ +++++++++++++++++++++++++++++++++++++\ |
\ +++++++++++++++++++++++++++++++++++++\ |
||
! /+++++++++++++++++++++++++++++++++++++/ |
! /+++++++++++++++++++++++++++++++++++++/ |
||
/ \..<+++++\ |
/ \..<+++++\ |
||
\ . +++++/ |
\ . +++++/ |
||
</ |
</syntaxhighlight> as J.snusp |
||
<pre> |
<pre> |
||
load'snusp.ijs' NB. the j code above |
load'snusp.ijs' NB. the j code above |
||
Line 373: | Line 373: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
This Modular SNUSP interpreter uses modular calls to echo the first 2 characters entered. Try typing "Hi" at the prompt. |
This Modular SNUSP interpreter uses modular calls to echo the first 2 characters entered. Try typing "Hi" at the prompt. |
||
< |
<syntaxhighlight lang="julia">const echo2 = raw""" |
||
/==!/======ECHO==,==.==# |
/==!/======ECHO==,==.==# |
||
| | |
| | |
||
Line 427: | Line 427: | ||
end |
end |
||
snusp(100, echo2)</ |
snusp(100, echo2)</syntaxhighlight> {{output}} <pre> |
||
> Hi |
> Hi |
||
Hi |
Hi |
||
Line 435: | Line 435: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
< |
<syntaxhighlight lang="scala">// version 1.1.2 |
||
// requires 5 chars (10 bytes) of data store |
// requires 5 chars (10 bytes) of data store |
||
Line 497: | Line 497: | ||
fun main(args: Array<String>) { |
fun main(args: Array<String>) { |
||
snusp(5, hw) |
snusp(5, hw) |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 512: | Line 512: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="nim">import strutils |
||
# Requires 5 bytes of data store. |
# Requires 5 bytes of data store. |
||
Line 571: | Line 571: | ||
when isMainModule: |
when isMainModule: |
||
snusp(5, Hw)</ |
snusp(5, Hw)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 584: | Line 584: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<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> |
<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: | Line 646: | ||
<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> |
<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> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 657: | Line 657: | ||
=={{header|Python}}== |
=={{header|Python}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
< |
<syntaxhighlight lang="python">#!/usr/bin/env python3 |
||
HW = r''' |
HW = r''' |
||
Line 711: | Line 711: | ||
if __name__ == '__main__': |
if __name__ == '__main__': |
||
snusp(5, HW)</ |
snusp(5, HW)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 724: | Line 724: | ||
{{works with|Rakudo|2017.02}} |
{{works with|Rakudo|2017.02}} |
||
Implementation of modular SNUSP. |
Implementation of modular SNUSP. |
||
<lang |
<syntaxhighlight lang="raku" line>class SNUSP { |
||
has @!inst-pointer; |
has @!inst-pointer; |
||
Line 794: | Line 794: | ||
my $snusp = SNUSP.new; |
my $snusp = SNUSP.new; |
||
$snusp.run($hw)</ |
$snusp.run($hw)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Hello World!</pre> |
<pre>Hello World!</pre> |
||
Line 804: | Line 804: | ||
The interpreter below implements Core SNUSP: |
The interpreter below implements Core SNUSP: |
||
< |
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i"; |
||
const proc: snusp (in string: sourceCode, in integer: memSize, inout file: input, inout file: output) is func |
const proc: snusp (in string: sourceCode, in integer: memSize, inout file: input, inout file: output) is func |
||
Line 864: | Line 864: | ||
begin |
begin |
||
snusp(helloWorld, 5, IN, OUT); |
snusp(helloWorld, 5, IN, OUT); |
||
end func;</ |
end func;</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 876: | Line 876: | ||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
< |
<syntaxhighlight lang="ecmascript">import "io" for Stdin |
||
// 'raw' is a multi-line string |
// 'raw' is a multi-line string |
||
Line 949: | Line 949: | ||
"$+++/ | \\+++++++++>\\ \\+++++.>.+++.-----\\\n" + |
"$+++/ | \\+++++++++>\\ \\+++++.>.+++.-----\\\n" + |
||
" \\==-<<<<+>+++/ /=.>.+>.--------.-/" |
" \\==-<<<<+>+++/ /=.>.+>.--------.-/" |
||
snusp.call(5, hw)</ |
snusp.call(5, hw)</syntaxhighlight> |
||
{{out}} |
{{out}} |