Interactive programming (repl): Difference between revisions
m
→{{header|Wren}}: Version change.
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
m (→{{header|Wren}}: Version change.) |
||
(15 intermediate revisions by 6 users not shown) | |||
Line 384:
ELENA Script is a subset of the general language. ELT (Virtual machine terminal) can work in REPL mode
<syntaxhighlight lang="elena">
c:\Alex\ELENA\bin>elt-cli
ELENA command line VM terminal
ELENA VM
Initializing...
-q - quit
-c - clear
-h - help
-l <path> - execute a script from file
-p<script>; - prepend the prefix code
{ <script>; }*
<script> - execute script
>
>f("Rosetta","Code",":")
Line 555 ⟶ 561:
=={{header|Fōrmulæ}}==
The interactive mode (REPL) is the primary working mode in Fōrmulæ.
To use it, open the web address [https://formulae.org/ formulae.org] in your browser. it is preferable to use this environment in a desktop web browser.
It is not necessary to install anything else.
A page with information is shown. You can start a new script using the [[File:Fōrmulæ - Interactive programming 05.png|border]] tool (new document).
[[File:Fōrmulæ - Interactive programming 04.png|border]]
=={{header|GAP}}==
Line 666 ⟶ 676:
WRITE(ClipBoard) TRIM(A) // ':' // TRIM(C) // TRIM(B) ! Rosetta::Code</syntaxhighlight>
=={{Header|Insitux}}==
First is the system shell, when Insitux has been already been installed system-wide (<code>npm i -g insitux</code>).
<pre>
$ npx ix
Insitux 230728 REPL
❯ (function f s1 s2 sep (str s1 sep sep s2))
❯ (f "Rosetta" "Code" ":")
Rosetta::Code
❯
</pre>
=={{header|Io}}==
Line 705 ⟶ 728:
Rosetta::Code
</syntaxhighlight>
Alternatively
<syntaxhighlight lang="java">
Java has an interactive REPL (Read-Evaluate-Print-Loop) console, jshell, that is included with the JDK.
The REPL is started by invoking: $JAVA_HOME/bin/jshell
Here is a sample session to accomplish the task.
| Welcome to JShell -- Version 20
| For an introduction type: /help
jshell> String concat(String a, String b, String c) { return a + c + c + b; }
| created method concat(String, String, String)
jshell> concat("Rosetta", "Code", ":")
$2 ==> "Rosetta::Code"
jshell>
</syntaxhighlight>
Line 769 ⟶ 809:
Rosetta::Code
>>> :quit</syntaxhighlight>
=={{header|Lambdatalk}}==
Lambdatalk works in a small wiki, lambdatank. Evaluation is done in real time.
<syntaxhighlight lang="scheme">
{def F {lambda {:a :b :s} :a:s:s:b}}
-> F
{F Rosetta Code :}
-> Rosetta::Code
</syntaxhighlight>
=={{header|Lang}}==
This example works with the LangShell from the Standard Lang implementation.
The LangShell can be started with (The LangShell does not run in the OS's shell, it will open a separate window):
<syntaxhighlight lang="shell">
$ lang -startShell
</syntaxhighlight>
<syntaxhighlight lang="lang">
Lang-Shell - Press CTRL + C for cancelling execution or for exiting!
• Copy with (CTRL + SHIFT + C) and paste with (CTRL + SHIT + V)
• Press CTRL + S for saving all inputs to a .lang file (Save)
• Press CTRL + SHIFT + S for saving all inputs to a .lang file (Save As...)
• Press CTRL + I for opening the special char input window
• Press CTRL + SHIFT + F for opening a file chooser to insert file paths
• Press UP and DOWN for scrolling through the history
• Press TAB and SHIFT + TAB for scrolling trough auto complete texts
◦ Press ENTER for accepting the auto complete text
• Press CTRL + L to clear the screen
• Use func.printHelp() to get information about LangShell functions
> fp.f = ($a, $b, $s) -> return $a$s$s$b
==> <Normal FP>
> fp.f(Rosetta, Code, :)
==> Rosetta::Code
>
</syntaxhighlight>
Example with auto print mode set to NONE:
<syntaxhighlight lang="lang">
Lang-Shell - Press CTRL + C for cancelling execution or for exiting!
• Copy with (CTRL + SHIFT + C) and paste with (CTRL + SHIT + V)
• Press CTRL + S for saving all inputs to a .lang file (Save)
• Press CTRL + SHIFT + S for saving all inputs to a .lang file (Save As...)
• Press CTRL + I for opening the special char input window
• Press CTRL + SHIFT + F for opening a file chooser to insert file paths
• Press UP and DOWN for scrolling through the history
• Press TAB and SHIFT + TAB for scrolling trough auto complete texts
◦ Press ENTER for accepting the auto complete text
• Press CTRL + L to clear the screen
• Use func.printHelp() to get information about LangShell functions
> fn.setAutoPrintMode(NONE)
> fp.f = ($a, $b, $s) -> return $a$s$s$b
> fn.println(fp.f(Rosetta, Code, :))
Rosetta::Code
>
</syntaxhighlight>
=={{header|Lasso}}==
Line 818 ⟶ 912:
Result -> Rosetta::Code
=={{header|Lingo}}==
Line 1,484 ⟶ 1,568:
</pre>
=={{header|RPL}}==
RPL command-line interpreter is permanently running. Each created function can be called by its name, the same way as built-in instructions, without any prefix.
≪ "::" SWAP + + ≫ ‘FUNC’ STO
"Rosetta" "Code" FUNC
{{out}}
<pre>
1: "Rosetta::Code"
</pre>
=={{header|Ruby}}==
The read-eval-print loop (REPL) for Ruby is ''irb'', the '''''i'''nteractive '''r'''u'''b'''y shell''.
Line 1,865 ⟶ 1,957:
$ ./wren
\\/"-
\_/ wren v0.
> var f = Fn.new { |s1, s2, sep| s1 + sep + sep + s2 }
> f.call("Rosetta", "Code", ":")
|