Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
6
Task/Copy-a-string/Apex/copy-a-string.apex
Normal file
6
Task/Copy-a-string/Apex/copy-a-string.apex
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
String original = 'Test';
|
||||
String cloned = original;
|
||||
//"original == cloned" is true
|
||||
|
||||
cloned += ' more';
|
||||
//"original == cloned" is false
|
||||
10
Task/Copy-a-string/Axe/copy-a-string.axe
Normal file
10
Task/Copy-a-string/Axe/copy-a-string.axe
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
Lbl STRCPY
|
||||
r₁→S
|
||||
While {r₂}
|
||||
{r₂}→{r₁}
|
||||
r₁++
|
||||
r₂++
|
||||
End
|
||||
0→{r₁}
|
||||
S
|
||||
Return
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
ldsrc: LDA src
|
||||
stdest: STA dest
|
||||
BRZ done ; 0-terminated
|
||||
|
||||
LDA ldsrc
|
||||
ADD one
|
||||
STA ldsrc
|
||||
|
||||
LDA stdest
|
||||
ADD one
|
||||
STA stdest
|
||||
|
||||
JMP ldsrc
|
||||
|
||||
done: STP
|
||||
|
||||
one: 1
|
||||
|
||||
src: 82 ; ASCII
|
||||
111
|
||||
115
|
||||
101
|
||||
116
|
||||
116
|
||||
97
|
||||
0
|
||||
|
||||
dest:
|
||||
6
Task/Copy-a-string/EchoLisp/copy-a-string.echolisp
Normal file
6
Task/Copy-a-string/EchoLisp/copy-a-string.echolisp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(define-syntax-rule (string-copy s) (string-append s)) ;; copy = append nothing
|
||||
→ #syntax:string-copy
|
||||
(define s "abc")
|
||||
(define t (string-copy s))
|
||||
t → "abc"
|
||||
(eq? s t) → #t ;; same reference, same object
|
||||
12
Task/Copy-a-string/FreeBASIC/copy-a-string.freebasic
Normal file
12
Task/Copy-a-string/FreeBASIC/copy-a-string.freebasic
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim s As String = "This is a string"
|
||||
Dim t As String = s
|
||||
' a separate copy of the string contents has been made as can be seen from the addresses
|
||||
Print s, StrPtr(s)
|
||||
Print t, StrPtr(t)
|
||||
' to refer to the same string a pointer needs to be used
|
||||
Dim u As String Ptr = @s
|
||||
Print
|
||||
Print *u, StrPtr(*u)
|
||||
Sleep
|
||||
6
Task/Copy-a-string/FutureBasic/copy-a-string.futurebasic
Normal file
6
Task/Copy-a-string/FutureBasic/copy-a-string.futurebasic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
dim as Str15 s, c
|
||||
s = "Hello!"
|
||||
c = s
|
||||
print c
|
||||
6
Task/Copy-a-string/I/copy-a-string.i
Normal file
6
Task/Copy-a-string/I/copy-a-string.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
//Text is mutable.
|
||||
software {
|
||||
var s = "Hello"
|
||||
var c = copy(s)
|
||||
print(c)
|
||||
}
|
||||
22
Task/Copy-a-string/LC3-Assembly/copy-a-string.lc3
Normal file
22
Task/Copy-a-string/LC3-Assembly/copy-a-string.lc3
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
.ORIG 0x3000
|
||||
|
||||
LEA R1,SRC
|
||||
LEA R2,COPY
|
||||
|
||||
LOOP LDR R3,R1,0
|
||||
STR R3,R2,0
|
||||
BRZ DONE
|
||||
ADD R1,R1,1
|
||||
ADD R2,R2,1
|
||||
BRNZP LOOP
|
||||
|
||||
DONE LEA R0,COPY
|
||||
PUTS
|
||||
|
||||
HALT
|
||||
|
||||
SRC .STRINGZ "What, has this thing appeared again tonight?"
|
||||
|
||||
COPY .BLKW 128
|
||||
|
||||
.END
|
||||
3
Task/Copy-a-string/LFE/copy-a-string-1.lfe
Normal file
3
Task/Copy-a-string/LFE/copy-a-string-1.lfe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
(let* ((a '"data assigned to a")
|
||||
(b a))
|
||||
(: io format '"Contents of 'b': ~s~n" (list b)))
|
||||
8
Task/Copy-a-string/LFE/copy-a-string-2.lfe
Normal file
8
Task/Copy-a-string/LFE/copy-a-string-2.lfe
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
> (set a '"data")
|
||||
"data"
|
||||
> a
|
||||
"data"
|
||||
> (set b a)
|
||||
"data"
|
||||
> b
|
||||
"data"
|
||||
18
Task/Copy-a-string/Lasso/copy-a-string.lasso
Normal file
18
Task/Copy-a-string/Lasso/copy-a-string.lasso
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
local(x = 'I saw a rhino!')
|
||||
local(y = #x)
|
||||
|
||||
#x //I saw a rhino!
|
||||
'\r'
|
||||
#y //I saw a rhino!
|
||||
|
||||
'\r\r'
|
||||
#x = 'I saw one too'
|
||||
#x //I saw one too
|
||||
'\r'
|
||||
#y //I saw a rhino!
|
||||
|
||||
'\r\r'
|
||||
#y = 'it was grey.'
|
||||
#x //I saw one too
|
||||
'\r'
|
||||
#y //it was grey.
|
||||
2
Task/Copy-a-string/Lingo/copy-a-string-1.lingo
Normal file
2
Task/Copy-a-string/Lingo/copy-a-string-1.lingo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
str = "Hello world!"
|
||||
str2 = str
|
||||
5
Task/Copy-a-string/Lingo/copy-a-string-2.lingo
Normal file
5
Task/Copy-a-string/Lingo/copy-a-string-2.lingo
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
put "X" before str
|
||||
put "X" after str
|
||||
put "X" into char 6 of str
|
||||
put str
|
||||
-- "XHellX world!X"
|
||||
3
Task/Copy-a-string/LiveCode/copy-a-string.livecode
Normal file
3
Task/Copy-a-string/LiveCode/copy-a-string.livecode
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
put "foo" into bar
|
||||
put bar into baz
|
||||
answer bar && baz
|
||||
3
Task/Copy-a-string/Nim/copy-a-string.nim
Normal file
3
Task/Copy-a-string/Nim/copy-a-string.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var
|
||||
c = "This is a string"
|
||||
d = c # Copy of content into new string
|
||||
1
Task/Copy-a-string/Oforth/copy-a-string-1.oforth
Normal file
1
Task/Copy-a-string/Oforth/copy-a-string-1.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
"abcde" dup
|
||||
1
Task/Copy-a-string/Oforth/copy-a-string-2.oforth
Normal file
1
Task/Copy-a-string/Oforth/copy-a-string-2.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
StringBuffer new "abcde" <<
|
||||
5
Task/Copy-a-string/Phix/copy-a-string.phix
Normal file
5
Task/Copy-a-string/Phix/copy-a-string.phix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
string this = "feed"
|
||||
string that = this -- (that becomes "feed", this remains "feed")
|
||||
that[2..3] = "oo" -- (that becomes "food", this remains "feed")
|
||||
this[1] = 'n' -- (that remains "food", this becomes "need")
|
||||
?{this,that}
|
||||
2
Task/Copy-a-string/Ring/copy-a-string.ring
Normal file
2
Task/Copy-a-string/Ring/copy-a-string.ring
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
cStr1 = "Hello!" # create original string
|
||||
cStr2 = cStr1 # make new string from original
|
||||
4
Task/Copy-a-string/Sidef/copy-a-string.sidef
Normal file
4
Task/Copy-a-string/Sidef/copy-a-string.sidef
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var original = "hello"; # new String object
|
||||
var reference = original; # points at the original object
|
||||
var copy1 = String.new(original); # creates a new String object
|
||||
var copy2 = original+''; # ==//==
|
||||
2
Task/Copy-a-string/Swift/copy-a-string.swift
Normal file
2
Task/Copy-a-string/Swift/copy-a-string.swift
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var src = "Hello"
|
||||
var dst = src
|
||||
3
Task/Copy-a-string/Ursa/copy-a-string.ursa
Normal file
3
Task/Copy-a-string/Ursa/copy-a-string.ursa
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
decl string a b
|
||||
set a "hello"
|
||||
set b a
|
||||
8
Task/Copy-a-string/jq/copy-a-string.jq
Normal file
8
Task/Copy-a-string/jq/copy-a-string.jq
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def demo:
|
||||
"abc" as $s # assignment of a string to a variable
|
||||
| $s as $t # $t points to the same string as $s
|
||||
| "def" as $s # This $s shadows the previous $s
|
||||
| $t # $t still points to "abc"
|
||||
;
|
||||
|
||||
demo
|
||||
Loading…
Add table
Add a link
Reference in a new issue