Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
3
Task/Interactive-programming-repl-/00-META.yaml
Normal file
3
Task/Interactive-programming-repl-/00-META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Interactive_programming_(repl)
|
||||
note: Basic language learning
|
||||
23
Task/Interactive-programming-repl-/00-TASK.txt
Normal file
23
Task/Interactive-programming-repl-/00-TASK.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Many language implementations come with an ''interactive mode''.
|
||||
|
||||
This is a [[wp:command-line interpreter|command-line interpreter]] that reads lines from the user and evaluates these lines as statements or expressions.
|
||||
|
||||
An interactive mode may also be known as a ''command mode'', a ''[[wp:read-eval-print loop|read-eval-print loop]]'' (REPL), or a ''shell''.
|
||||
|
||||
|
||||
;Task:
|
||||
Show how to start this mode.
|
||||
|
||||
Then, as a small example of its use, interactively create a function of two strings and a separator that returns the strings separated by two concatenated instances of the separator (the 3<sup>rd</sup> argument).
|
||||
|
||||
|
||||
;Example:
|
||||
<big> f('Rosetta', 'Code', ':') </big>
|
||||
should return
|
||||
<big> 'Rosetta::Code' </big>
|
||||
|
||||
|
||||
;Note:
|
||||
This task is ''not'' about creating your own interactive mode.
|
||||
<br><br>
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
] 0 IF F$ = "F" THEN RESULT$ = P1$ + P3$ + P3$ + P2$: END
|
||||
|
||||
] F$ = "F":P1$ = "ROSETTA":P2$ = "CODE":P3$ = ":": GOTO
|
||||
|
||||
] ?RESULT$
|
||||
ROSETTA::CODE
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
10 DEF FN f$(a$, b$, s$) = a$+s$+s$+b$
|
||||
PRINT FN f$("Rosetta", "Code", ":")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Join ← {a 𝕊 b‿c: b∾a∾a∾c}
|
||||
(function block)
|
||||
":" Join "Rosetta"‿"Code"
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
>set r=Rosetta
|
||||
|
||||
>set c=Code
|
||||
|
||||
>set s=:
|
||||
|
||||
>echo %r%%s%%s%%c%
|
||||
Rosetta::Code
|
||||
|
||||
>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
$ brat
|
||||
# Interactive Brat
|
||||
brat:1> f = { a, b, s | a + s + s + b }
|
||||
#=> function: 0xb737ac08
|
||||
brat:2> f "Rosetta" "Code" ":"
|
||||
#=> Rosetta::Code
|
||||
brat:3> quit
|
||||
Exiting
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
C:\Burlesque>Burlesque.exe --shell
|
||||
blsq ) {+]?+}hd"Rosetta""Code"':!a
|
||||
"Rosetta:Code"
|
||||
blsq )
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ csh -f
|
||||
% alias concat 'echo "\!:1\!:3\!:3\!:2"'
|
||||
% concat Rosetta Code :
|
||||
Rosetta::Code
|
||||
%
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
Clojure 1.1.0
|
||||
user=> (defn f [s1 s2 sep] (str s1 sep sep s2))
|
||||
#'user/f
|
||||
user=> (f "Rosetta" "Code" ":")
|
||||
"Rosetta::Code"
|
||||
user=>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ coffee -n
|
||||
coffee> f = (a, b, c) -> a + c + c + b
|
||||
[Function]
|
||||
coffee> f "Rosetta", "Code", ":"
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
$ rlwrap sbcl
|
||||
This is SBCL 1.0.25, an implementation of ANSI Common Lisp.
|
||||
More information about SBCL is available at <http://www.sbcl.org/>.
|
||||
...
|
||||
* (defun f (string-1 string-2 separator)
|
||||
(concatenate 'string string-1 separator separator string-2))
|
||||
|
||||
F
|
||||
* (f "Rosetta" "Code" ":")
|
||||
|
||||
"Rosetta::Code"
|
||||
*
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ rune # from an OS shell. On Windows there is also a desktop shortcut.
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
? def f(string1 :String, string2 :String, separator :String) {
|
||||
> return separator.rjoin(string1, "", string2)
|
||||
> }
|
||||
# value: <f>
|
||||
|
||||
? f("Rosetta", "Code", ":")
|
||||
# value: "Rosetta::Code"
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
;; screen copy of the REPL
|
||||
;; note that the &i variables remember expression evaluation, and may be used in other expressions
|
||||
|
||||
EchoLisp - 2.16.2
|
||||
📗 local-db: db.version: 3
|
||||
(define ( f s1 s2 s3) (string-append s1 s3 s3 s2))
|
||||
[0]→ f
|
||||
(f "Rosetta" "Code" ":")
|
||||
[1]→ "Rosetta::Code"
|
||||
(+ 4 8)
|
||||
[2]→ 12
|
||||
(* 4 8)
|
||||
[3]→ 32
|
||||
(* &2 &3)
|
||||
[4]→ 384
|
||||
(f &1 &1 ":")
|
||||
[5]→ "Rosetta::Code::Rosetta::Code"
|
||||
|
||||
;; etc.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
c:\Alex\ELENA\bin>elt
|
||||
ELENA command line VM terminal 5.1.13 (C)2011-2020 by Alexei Rakov
|
||||
ELENA VM 5.1.17 (C)2005-2020 by Alex Rakov
|
||||
Initializing...
|
||||
Done...
|
||||
|
||||
>f(s1,s2,sep){^ s1 + sep + sep + s2 };
|
||||
|
||||
>f("Rosetta","Code",":")
|
||||
Rosetta::Code
|
||||
>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
iex(1)> f = fn str1,str2,sep -> [str1,"",str2] |> Enum.join(sep) end # Join list on separator
|
||||
iex(2)> g = fn str1,str2,sep -> str1 <> sep <> sep <> str2 end # Or concatenate strings
|
||||
|
||||
iex(3)> defmodule JoinStrings do
|
||||
...(3)> def f(str1,str2,sep), do: [str1,"",str2] |> Enum.join(sep)
|
||||
...(3)> def g(str1,str2,sep), do: str1 <> sep <> sep <> str2
|
||||
...(3)> end
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
iex(4)> f.("Rosetta","Code",":")
|
||||
"Rosetta::Code"
|
||||
iex(5)> JoinStrings.f("Rosetta","Code",":")
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(defun my-join (str1 str2 sep)
|
||||
(concat str1 sep sep str2))
|
||||
my-join
|
||||
(my-join "Rosetta" "Code" ":")
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
*** Welcome to IELM *** Type (describe-mode) for help.
|
||||
ELISP> (defun my-join (str1 str2 sep)
|
||||
(concat str1 sep sep str2))
|
||||
my-join
|
||||
ELISP> (my-join "Rosetta" "Code" ":")
|
||||
"Rosetta::Code"
|
||||
ELISP>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$erl
|
||||
1> F = fun(X,Y,Z) -> string:concat(string:concat(X,Z),string:concat(Z,Y)) end.
|
||||
#Fun<erl_eval.18.105910772>
|
||||
2> F("Rosetta", "Code", ":").
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ es
|
||||
; fn concat a b s { result $a$s$s$b }
|
||||
; echo <={concat Rosetta Code :}
|
||||
Rosetta::Code
|
||||
;
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
Microsoft F# Interactive, (c) Microsoft Corporation, All Rights Reserved
|
||||
F# Version 1.9.6.2, compiling for .NET Framework Version v2.0.50727
|
||||
|
||||
Please send bug reports to fsbugs@microsoft.com
|
||||
For help type #help;;
|
||||
|
||||
> let f a b sep = String.concat sep [a; ""; b] ;;
|
||||
|
||||
val f : string -> string -> string -> string
|
||||
|
||||
> f "Rosetta" "Code" ":" ;;
|
||||
val it : string = "Rosetta::Code"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
( scratchpad ) : cool-func ( w1 w2 sep -- res ) dup append glue ;
|
||||
( scratchpad ) "Rosetta" "Code" ":" cool-func .
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
$ gforth
|
||||
Gforth 0.7.0, Copyright (C) 1995-2008 Free Software Foundation, Inc.
|
||||
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
|
||||
Type `bye' to exit
|
||||
ok
|
||||
: f ( separator suffix prefix -- ) compiled
|
||||
pad place 2swap 2dup compiled
|
||||
pad +place compiled
|
||||
pad +place compiled
|
||||
pad +place compiled
|
||||
pad count ; ok
|
||||
ok
|
||||
s" :" s" Code" s" Rosetta" f cr type
|
||||
Rosetta::Code ok
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim As String s1, s2, sep
|
||||
Input "First string "; s1
|
||||
Input "Second string "; s2
|
||||
Input "Separator "; sep
|
||||
Print : Print s1 + sep + sep + s2
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$ java -cp frink.jar frink.parser.Frink
|
||||
|
||||
f[a,b,s] := "$a$s$s$b"
|
||||
f["Rosetta", "Code", ":"]
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
~% gap
|
||||
|
||||
######### ###### ########### ###
|
||||
############# ###### ############ ####
|
||||
############## ######## ############# #####
|
||||
############### ######## ##### ###### #####
|
||||
###### # ######### ##### ##### ######
|
||||
###### ########## ##### ##### #######
|
||||
##### ##### #### ##### ###### ########
|
||||
#### ##### ##### ############# ### ####
|
||||
##### ####### #### #### ########### #### ####
|
||||
##### ####### ##### ##### ###### #### ####
|
||||
##### ####### ##### ##### ##### #############
|
||||
##### ##### ################ ##### #############
|
||||
###### ##### ################ ##### #############
|
||||
################ ################## ##### ####
|
||||
############### ##### ##### ##### ####
|
||||
############# ##### ##### ##### ####
|
||||
######### ##### ##### ##### ####
|
||||
|
||||
Information at: http://www.gap-system.org
|
||||
Try '?help' for help. See also '?copyright' and '?authors'
|
||||
|
||||
Loading the library. Please be patient, this may take a while.
|
||||
GAP4, Version: 4.4.12 of 17-Dec-2008, x86_64-unknown-linux-gnu-gcc
|
||||
Components: small 2.1, small2 2.0, small3 2.0, small4 1.0, small5 1.0, small6 1.0, small7 1.0, small8 1.0,
|
||||
small9 1.0, small10 0.2, id2 3.0, id3 2.1, id4 1.0, id5 1.0, id6 1.0, id9 1.0, id10 0.1, trans 1.0,
|
||||
prim 2.1 loaded.
|
||||
Packages: AClib 1.1, Polycyclic 2.6, Alnuth 2.2.5, AutPGrp 1.4, CrystCat 1.1.3, Cryst 4.1.6, CRISP 1.3.2,
|
||||
CTblLib 1.1.3, TomLib 1.1.4, FactInt 1.5.2, GAPDoc 1.2, FGA 1.1.0.1, IRREDSOL 1.1.2, LAGUNA 3.5.0,
|
||||
Sophus 1.23, Polenta 1.2.7, ResClasses 2.5.3 loaded.
|
||||
gap> join := function(a, b, sep)
|
||||
> return Concatenation(a, sep, sep, b);
|
||||
> end;
|
||||
function( a, b, sep ) ... end
|
||||
gap>
|
||||
gap> join("Rosetta", "Code", ":");
|
||||
"Rosetta::Code"
|
||||
gap>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func f(s1, s2, sep string) string {
|
||||
return s1 + sep + sep + s2
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(f("Rosetta", "Code", ":"))
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
C:\Apps\groovy>groovysh
|
||||
Groovy Shell (1.6.2, JVM: 1.6.0_13)
|
||||
Type 'help' or '\h' for help.
|
||||
---------------------------------------------------------------------------------------------------
|
||||
groovy:000> f = { a, b, sep -> a + sep + sep + b }
|
||||
===> groovysh_evaluate$_run_closure1@5e8d7d
|
||||
groovy:000> println f('Rosetta','Code',':')
|
||||
Rosetta::Code
|
||||
===> null
|
||||
groovy:000> exit
|
||||
|
||||
C:\Apps\groovy>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
$ ghci
|
||||
___ ___ _
|
||||
/ _ \ /\ /\/ __(_)
|
||||
/ /_\// /_/ / / | | GHC Interactive, version 6.4.2, for Haskell 98.
|
||||
/ /_\\/ __ / /___| | http://www.haskell.org/ghc/
|
||||
\____/\/ /_/\____/|_| Type :? for help.
|
||||
|
||||
Loading package base-1.0 ... linking ... done.
|
||||
Prelude> let f as bs sep = as ++ sep ++ sep ++ bs
|
||||
Prelude> f "Rosetta" "Code" ":"
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
CHARACTER A*40, B*40, C*40
|
||||
|
||||
READ(Text=$CMD_LINE, Format="'','','',") A, B, C
|
||||
WRITE(ClipBoard, Name) A, B, C ! A=Rosetta; B=Code; C=:;
|
||||
|
||||
WRITE(ClipBoard) TRIM(A) // ':' // TRIM(C) // TRIM(B) ! Rosetta::Code
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
f=: [: ; 0 2 2 1&{
|
||||
f 'Rosetta';'Code';':'
|
||||
Rosetta::Code
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
public static void main(String[] args) {
|
||||
System.out.println(concat("Rosetta", "Code", ":"));
|
||||
}
|
||||
|
||||
public static String concat(String a, String b, String c) {
|
||||
return a + c + c + b;
|
||||
}
|
||||
|
||||
Rosetta::Code
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
$ java -cp js.jar org.mozilla.javascript.tools.shell.Main
|
||||
Rhino 1.7 release 2 2009 03 22
|
||||
js> function f(a,b,s) {return a + s + s + b;}
|
||||
js> f('Rosetta', 'Code', ':')
|
||||
Rosetta::Code
|
||||
js> quit()
|
||||
$
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ rlwrap k
|
||||
K Console - Enter \ for help
|
||||
f:{x,z,z,y}
|
||||
f["Rosetta";"Code";":"]
|
||||
"Rosetta::Code"
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
c:\kotlin-compiler-1.0.6>kotlinc
|
||||
Welcome to Kotlin version 1.0.6-release-127 (JRE 1.8.0_31-b13)
|
||||
Type :help for help, :quit for quit
|
||||
>>> fun f(s1: String, s2: String, sep: String) = s1 + sep + sep + s2
|
||||
>>> f("Rosetta", "Code", ":")
|
||||
Rosetta::Code
|
||||
>>> :quit
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{def F {lambda {:a :b :s} :a:s:s:b}}
|
||||
-> F
|
||||
|
||||
{F Rosetta Code :}
|
||||
-> Rosetta::Code
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ lang -startShell
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
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
|
||||
>
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
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
|
||||
>
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/lasso9
|
||||
|
||||
// filename: interactive_demo
|
||||
|
||||
define concatenate_with_delimiter(
|
||||
string1::string,
|
||||
string2::string,
|
||||
delimiter::string
|
||||
|
||||
) => #string1 + (#delimiter*2) + #string2
|
||||
|
||||
define read_input(prompt::string) => {
|
||||
|
||||
local(string)
|
||||
|
||||
// display prompt
|
||||
stdout(#prompt)
|
||||
// the following bits wait until the terminal gives you back a line of input
|
||||
while(not #string or #string -> size == 0) => {
|
||||
#string = file_stdin -> readsomebytes(1024, 1000)
|
||||
}
|
||||
#string -> replace(bytes('\n'), bytes(''))
|
||||
|
||||
return #string -> asstring
|
||||
}
|
||||
|
||||
local(
|
||||
string1,
|
||||
string2,
|
||||
delimiter
|
||||
)
|
||||
|
||||
// get first string
|
||||
#string1 = read_input('Enter the first string: ')
|
||||
|
||||
// get second string
|
||||
#string2 = read_input('Enter the second string: ')
|
||||
|
||||
// get delimiter
|
||||
#delimiter = read_input('Enter the delimiter: ')
|
||||
|
||||
// deliver the result
|
||||
stdoutnl(concatenate_with_delimiter(#string1, #string2, #delimiter))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
> m=new(#script)
|
||||
> m.scripttext="on conc(a,b,c)"&RETURN&"return a&c&c&b"&RETURN&"end"
|
||||
> put conc("Rosetta", "Code", ":")
|
||||
-- "Rosetta::Code"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
$ <i>logo</i>
|
||||
Welcome to Berkeley Logo version 5.6
|
||||
? <i>to f :prefix :suffix :separator</i>
|
||||
> <i>output (word :prefix :separator :separator :suffix)</i>
|
||||
> <i>end</i>
|
||||
f defined
|
||||
? <i>show f "Rosetta "Code ":</i>
|
||||
Rosetta::Code
|
||||
?
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
$ lua
|
||||
Lua 5.1.2 Copyright (C) 1994-2007 Lua.org, PUC-Rio
|
||||
> function conc(a, b, c)
|
||||
>> return a..c..c..b
|
||||
>> end
|
||||
> print(conc("Rosetta", "Code", ":"))
|
||||
Rosetta::Code
|
||||
>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
Read name1$, name2$, sep$
|
||||
=name1$+sep$+sep$+name2$
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
$ m4
|
||||
define(`f',`$1`'$3`'$3`'$2')
|
||||
==>
|
||||
f(`Rosetta',`Code',`:')
|
||||
==>Rosetta::Code
|
||||
m4exit
|
||||
|
|
@ -0,0 +1 @@
|
|||
>> f = @(str1, str2, delim) [str1, delim, delim, str2];
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
MCSKIP MT,<>
|
||||
MCINS %.
|
||||
MCDEF F WITHS (,,)
|
||||
AS <%WA1.%WA3.%WA2.%WA2.>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
f := (a,b,c)->cat(a,c,c,b):
|
||||
|
||||
f("Rosetta","Code",":");
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ math
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
f[x_,y_,z_]:=Print[x,z,z,y]
|
||||
->""
|
||||
f["Rosetta","Code",":"]
|
||||
->Rosetta::Code
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
(%i1) f(a, b, c) := sconcat(a, c, c, b)$
|
||||
(%i2) f("Rosetta", "Code", ":");
|
||||
(%o2) "Rosetta::Code"
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$ (dup suffix swap suffix suffix) :glue
|
||||
$ "Rosetta" "Code" ":" glue puts!
|
||||
Rosetta::Code
|
||||
$
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
proc f(x, y, z: string) = echo x, z, z, y
|
||||
f("Rosetta", "Code", ":")
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
import ../compiler/[nimeval, llstream]
|
||||
|
||||
runRepl(llStreamOpenStdIn().repl, [findNimStdLibCompileTime()], true)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
$ ocaml
|
||||
Objective Caml version 3.12.1
|
||||
|
||||
# let f s1 s2 sep = String.concat sep [s1; ""; s2];;
|
||||
val f : string -> string -> string -> string = <fun>
|
||||
# f "Rosetta" "Code" ":";;
|
||||
- : string = "Rosetta::Code"
|
||||
#
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ rlwrap ocaml
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
$ octave
|
||||
GNU Octave, version 3.0.2
|
||||
Copyright (C) 2008 John W. Eaton and others.
|
||||
This is free software; see the source code for copying conditions.
|
||||
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTIBILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. For details, type `warranty'.
|
||||
|
||||
Octave was configured for "i586-mandriva-linux-gnu".
|
||||
|
||||
Additional information about Octave is available at http://www.octave.org.
|
||||
|
||||
Please contribute if you find this software useful.
|
||||
For more information, visit http://www.octave.org/help-wanted.html
|
||||
|
||||
Report bugs to <bug@octave.org> (but first, please read
|
||||
http://www.octave.org/bugs.html to learn how to write a helpful report).
|
||||
|
||||
For information about changes from previous versions, type `news'.
|
||||
|
||||
octave:1> function concat(a,b,c)
|
||||
> disp(strcat(a,c,c,b));
|
||||
> endfunction
|
||||
octave:2> concat("Rosetta","Code",":");
|
||||
Rosetta::Code
|
||||
octave:3>
|
||||
|
|
@ -0,0 +1 @@
|
|||
oforth --i
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
: x(a, b, sep) a sep + sep + b + ;
|
||||
ok
|
||||
>x("Rosetta", "Code", ":")
|
||||
ok
|
||||
>.s
|
||||
[1] (String) Rosetta::Code
|
||||
ok
|
||||
>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
> : x dup rot + + + ;
|
||||
ok
|
||||
> "Rosetta" "Code" ";" x .s
|
||||
[1] (String) Rosetta::Code
|
||||
ok
|
||||
>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
$ ol
|
||||
Welcome to Otus Lisp 2.1-2282-27a9b6c
|
||||
type ',help' to help, ',quit' to end session.
|
||||
> (define (f head tail mid)
|
||||
(string-append head mid mid tail))
|
||||
;; Defined f
|
||||
> (f "Rosetta" "Code" ":")
|
||||
"Rosetta::Code"
|
||||
> ,quit
|
||||
bye-bye :/
|
||||
|
|
@ -0,0 +1 @@
|
|||
declare fun {F As Bs Sep} {Append As Sep|Sep|Bs} end
|
||||
|
|
@ -0,0 +1 @@
|
|||
{System.showInfo {F "Rosetta" "Code" &:}}
|
||||
|
|
@ -0,0 +1 @@
|
|||
f(s1,s2,sep)=Str(s1, sep, sep, s2);
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
$ perl -de1
|
||||
|
||||
Loading DB routines from perl5db.pl version 1.3
|
||||
Editor support available.
|
||||
|
||||
Enter h or `h h' for help, or `man perldebug' for more help.
|
||||
|
||||
main::(-e:1): 1
|
||||
DB<1> sub f {my ($s1, $s2, $sep) = @_; $s1 . $sep . $sep . $s2}
|
||||
|
||||
DB<2> p f('Rosetta', 'Code', ':')
|
||||
Rosetta::Code
|
||||
DB<3> q
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
$ perl
|
||||
# Write the script here and press Ctrl+D plus ENTER when finished (^D means Ctrl+D):
|
||||
sub f {my ($s1, $s2, $sep) = @_; $s1 . $sep . $sep . $s2};
|
||||
print f('Rosetta', 'Code', ':');
|
||||
^D
|
||||
Rosetta::Code
|
||||
$
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ perl -lpe '$_=eval||$@'
|
||||
sub f { join '' => @_[0, 2, 2, 1] }
|
||||
|
||||
f qw/Rosetta Code :/
|
||||
Rosetta::Code
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ pil +
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
: (de f (Str1 Str2 Sep)
|
||||
(pack Str1 Sep Sep Str2) )
|
||||
-> f
|
||||
|
||||
: (f "Rosetta" "Code" ":")
|
||||
-> "Rosetta::Code"
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
$ pike
|
||||
Pike v7.8 release 352 running Hilfe v3.5 (Incremental Pike Frontend)
|
||||
> string f(string first, string second, string sep){
|
||||
>> return(first + sep + sep + second);
|
||||
>> }
|
||||
> f("Rosetta","Code",":");
|
||||
(1) Result: "Rosetta::Code"
|
||||
>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
Windows PowerShell
|
||||
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
|
||||
|
||||
PS Home:\> function f ([string] $string1, [string] $string2, [string] $separator) {
|
||||
>> $string1 + $separator * 2 + $string2
|
||||
>> }
|
||||
>>
|
||||
PS Home:\> f 'Rosetta' 'Code' ':'
|
||||
Rosetta::Code
|
||||
PS Home:\>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
% library(win_menu) compiled into win_menu 0.00 sec, 12,872 bytes
|
||||
% library(swi_hooks) compiled into pce_swi_hooks 0.00 sec, 2,404 bytes
|
||||
% The graphical front-end will be used for subsequent tracing
|
||||
% c:/users/joel-seven/appdata/roaming/swi-prolog/pl.ini compiled 0.13 sec, 876,172 bytes
|
||||
XPCE 6.6.66, July 2009 for Win32: NT,2000,XP
|
||||
Copyright (C) 1993-2009 University of Amsterdam.
|
||||
XPCE comes with ABSOLUTELY NO WARRANTY. This is free software,
|
||||
and you are welcome to redistribute it under certain conditions.
|
||||
The host-language is SWI-Prolog version 5.10.0
|
||||
|
||||
For HELP on prolog, please type help. or apropos(topic).
|
||||
on xpce, please type manpce.
|
||||
|
||||
1 ?- assert((f(A, B,C) :- format('~w~w~w~w~n', [A, C, C, B]))).
|
||||
true.
|
||||
|
||||
2 ?- f('Rosetta', 'Code', ':').
|
||||
Rosetta::Code
|
||||
true.
|
||||
|
||||
3 ?-
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
python
|
||||
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
|
||||
win32
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
>>> def f(string1, string2, separator):
|
||||
return separator.join([string1, '', string2])
|
||||
|
||||
>>> f('Rosetta', 'Code', ':')
|
||||
'Rosetta::Code'
|
||||
>>>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
$ quackery
|
||||
|
||||
Welcome to Quackery.
|
||||
|
||||
Enter "leave" to leave the shell.
|
||||
|
||||
/O> [ dup join swap join join ] is f ( [ [ [ --> [ )
|
||||
...
|
||||
|
||||
Stack empty.
|
||||
|
||||
/O> $ 'Rosetta' $ 'Code' $ ':' f
|
||||
...
|
||||
|
||||
Stack: [ 82 111 115 101 116 116 97 58 58 67 111 100 101 ]
|
||||
|
||||
/O> echo$
|
||||
...
|
||||
Rosetta::Code
|
||||
Stack empty.
|
||||
|
||||
/O>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
$ R
|
||||
|
||||
R version 2.7.2 (2008-08-25)
|
||||
Copyright (C) 2008 The R Foundation for Statistical Computing
|
||||
ISBN 3-900051-07-0
|
||||
|
||||
R is free software and comes with ABSOLUTELY NO WARRANTY.
|
||||
You are welcome to redistribute it under certain conditions.
|
||||
Type 'license()' or 'licence()' for distribution details.
|
||||
|
||||
Natural language support but running in an English locale
|
||||
|
||||
R is a collaborative project with many contributors.
|
||||
Type 'contributors()' for more information and
|
||||
'citation()' on how to cite R or R packages in publications.
|
||||
|
||||
Type 'demo()' for some demos, 'help()' for on-line help, or
|
||||
'help.start()' for an HTML browser interface to help.
|
||||
Type 'q()' to quit R.
|
||||
|
||||
> f <- function(a, b, s) paste(a, "", b, sep=s)
|
||||
> f("Rosetta", "Code", ":")
|
||||
[1] "Rosetta::Code"
|
||||
> q()
|
||||
Save workspace image? [y/n/c]: n
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
$ rebol -q
|
||||
>> f: func [a b s] [print rejoin [a s s b]]
|
||||
>> f "Rosetta" "Code" ":"
|
||||
Rosetta::Code
|
||||
>> q
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
/*REXX*/ parse arg a b c
|
||||
say f(a,b,c)
|
||||
exit
|
||||
f:return arg(1)arg(3)arg(3)arg(2)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
/*REXX program demonstrates interactive programming by using a function [F]. */
|
||||
say f('Rosetta', "Code", ':')
|
||||
say f('The definition of a trivial program is ', " one that has no bugs.", '───')
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
f: return arg(1) || copies(arg(3),2) || arg(2) /*return the required string to invoker*/
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/*REXX program demonstrates interactive programming by using a function [F]. */
|
||||
say '══════════════════ enter the function F with three comma-separated arguments:'
|
||||
parse pull funky
|
||||
interpret 'SAY' funky
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
f: return arg(1) || copies(arg(3),2) || arg(2) /*return the required string to invoker*/
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
oiseau:/tmp> racket
|
||||
Welcome to Racket v5.3.3.5.
|
||||
> (define (f string-1 string-2 separator)
|
||||
(string-append string-1 separator separator string-2))
|
||||
> (f "Rosetta" "Code" ":")
|
||||
"Rosetta::Code"
|
||||
> ^D
|
||||
oiseau:/tmp>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
$ rakudo/perl6
|
||||
> sub f($str1,$str2,$sep) { $str1~$sep x 2~$str2 };
|
||||
f
|
||||
> f("Rosetta","Code",":");
|
||||
Rosetta::Code
|
||||
>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
:f (sss-s) [ s:prepend ] sip s:prepend s:append ;
|
||||
'Rosetta 'Code ': f
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
r = "Rosetta"
|
||||
c = "Code"
|
||||
s = ":"
|
||||
see r+s+s+c
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
$ irb
|
||||
irb(main):001:0> def f(string1, string2, separator)
|
||||
irb(main):002:1> [string1, '', string2].join(separator)
|
||||
irb(main):003:1> end
|
||||
=> :f
|
||||
irb(main):004:0> f('Rosetta', 'Code', ':')
|
||||
=> "Rosetta::Code"
|
||||
irb(main):005:0> exit
|
||||
$
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
name: myapp
|
||||
version: "1.0"
|
||||
author: A Rust Developer <rustme@home.com>
|
||||
about: Does awesome things
|
||||
args:
|
||||
- STRING1:
|
||||
about: First string to use
|
||||
required: true
|
||||
index: 1
|
||||
- STRING2:
|
||||
about: Second string to use
|
||||
required: true
|
||||
index: 2
|
||||
- SEPARATOR:
|
||||
about: Separtor to use
|
||||
required: true
|
||||
index: 3
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
[dependencies]
|
||||
clap = { version = "3.0.0-beta.2", features = ["yaml"] }
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#[macro_use]
|
||||
extern crate clap;
|
||||
use clap::App;
|
||||
fn main() {
|
||||
let yaml = load_yaml!("cli.yaml");
|
||||
let matches = App::from(yaml).get_matches();
|
||||
|
||||
let str1 = matches.value_of("STRING1").unwrap();
|
||||
let str2 = matches.value_of("STRING2").unwrap();
|
||||
let str3 = matches.value_of("SEPARATOR").unwrap();
|
||||
|
||||
println!("{:?}", f(&str1, &str2, &str3));
|
||||
}
|
||||
|
||||
fn f<'a>(s1: &'a str, s2: &'a str, sep :&'a str) -> String{
|
||||
[s1,sep,sep,s2].iter().map(|x| *x).collect()
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
> slsh<Enter>
|
||||
slsh version 0.9.1-2; S-Lang version: pre2.3.1-23
|
||||
Copyright (C) 2005-2014 John E. Davis <jed@jedsoft.org>
|
||||
This is free software with ABSOLUTELY NO WARRANTY.
|
||||
|
||||
slsh> define f(s1, s2, sep) {<Enter>
|
||||
return(strcat(s1, sep, sep, s2));<Enter>
|
||||
}<Enter>
|
||||
slsh> f("Rosetta", "Code", ":");<Enter>
|
||||
Rosetta::Code
|
||||
slsh> quit<Enter>
|
||||
>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
C:\>scala
|
||||
Welcome to Scala version 2.8.0.r21356-b20100407020120 (Java HotSpot(TM) Client V
|
||||
M, Java 1.6.0_05).
|
||||
Type in expressions to have them evaluated.
|
||||
Type :help for more information.
|
||||
|
||||
scala> "rosetta"
|
||||
res0: java.lang.String = rosetta
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
scala> "rosetta".
|
||||
|
||||
!= ## $asInstanceOf
|
||||
$isInstanceOf + ==
|
||||
charAt clone codePointAt
|
||||
codePointBefore codePointCount compareTo
|
||||
compareToIgnoreCase concat contains
|
||||
contentEquals endsWith eq
|
||||
equals equalsIgnoreCase finalize
|
||||
getBytes getChars getClass
|
||||
hashCode indexOf intern
|
||||
isEmpty lastIndexOf length
|
||||
matches ne notify
|
||||
notifyAll offsetByCodePoints regionMatches
|
||||
replace replaceAll replaceFirst
|
||||
split startsWith subSequence
|
||||
substring synchronized this
|
||||
toCharArray toLowerCase toString
|
||||
toUpperCase trim wait
|
||||
|
||||
scala> "rosetta".+(":")
|
||||
res1: java.lang.String = rosetta:
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
scala> val str1 = "rosetta"
|
||||
str1: java.lang.String = rosetta
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
scala> val str2 = "code"
|
||||
str2: java.lang.String = code
|
||||
|
||||
scala> val separator = ":"
|
||||
separator: java.lang.String = :
|
||||
|
||||
scala> str1 + separator + str2
|
||||
res2: java.lang.String = rosetta:code
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
scala> def (str1: String, str2: String, separator: String) =
|
||||
<console>:1: error: identifier expected but '(' found.
|
||||
def (str1: String, str2: String, separator: String) =
|
||||
^
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
scala> def f(str1: String, str2: String, separator: String) =
|
||||
| str1 + separator + str2
|
||||
f: (str1: String,str2: String,separator: String)java.lang.String
|
||||
|
||||
scala> f("rosetta", "code", ":")
|
||||
res3: java.lang.String = rosetta:code
|
||||
|
||||
scala> f("code", "rosetta", ", ")
|
||||
res4: java.lang.String = code, rosetta
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
scala> .length
|
||||
res5: Int = 13
|
||||
|
||||
scala>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
scala> Array(1, 2, 3, 4)
|
||||
res8: Array[Int] = Array(1, 2, 3, 4)
|
||||
|
||||
scala> println(res8)
|
||||
[I@383244
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
> scheme
|
||||
Scheme Microcode Version 14.9
|
||||
MIT Scheme running under FreeBSD
|
||||
Type `^C' (control-C) followed by `H' to obtain information about interrupts.
|
||||
Scheme saved on Monday June 17, 2002 at 10:03:44 PM
|
||||
Release 7.7.1
|
||||
Microcode 14.9
|
||||
Runtime 15.1
|
||||
|
||||
1 ]=> (define (f string-1 string-2 separator)
|
||||
(string-append string-1 separator separator string-2))
|
||||
|
||||
;Value: f
|
||||
|
||||
1 ]=> (f "Rosetta" "Code" ":")
|
||||
|
||||
;Value 1: "Rosetta::Code"
|
||||
|
||||
1 ]=> ^D
|
||||
End of input stream reached
|
||||
Happy Happy Joy Joy.
|
||||
>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
> scheme48
|
||||
Welcome to Scheme 48 1.8 (made by root on Wed Sep 24 22:37:08 UTC 2008)
|
||||
Copyright (c) 1993-2008 by Richard Kelsey and Jonathan Rees.
|
||||
Please report bugs to scheme-48-bugs@s48.org.
|
||||
Get more information at http://www.s48.org/.
|
||||
Type ,? (comma question-mark) for help.
|
||||
> (define (f string-1 string-2 separator)
|
||||
(string-append string-1 separator separator string-2))
|
||||
; no values returned
|
||||
> (f "Rosetta" "Code" ":")
|
||||
"Rosetta::Code"
|
||||
> ^D
|
||||
Exit Scheme 48 (y/n)? ^D
|
||||
I'll only ask another 100 times.
|
||||
Exit Scheme 48 (y/n)? ^D
|
||||
I'll only ask another 99 times.
|
||||
Exit Scheme 48 (y/n)? y
|
||||
>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue