2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -1,6 +1,13 @@
|
|||
{{basic data operation}} [[Category:Simple]]
|
||||
{{basic data operation}}
|
||||
[[Category:Simple]]
|
||||
|
||||
Most languages provide a way to concatenate two string values, but some languages also provide a convenient way to append in-place to an existing string variable without referring to the variable twice.
|
||||
For this task, create a string variable equal to any text value.
|
||||
|
||||
|
||||
;Task:
|
||||
Create a string variable equal to any text value.
|
||||
|
||||
Append the string variable with another string literal in the most idiomatic way, without double reference if your language supports it.
|
||||
|
||||
Show the contents of the variable after the append operation.
|
||||
<br><br>
|
||||
|
|
|
|||
23
Task/String-append/COBOL/string-append.cobol
Normal file
23
Task/String-append/COBOL/string-append.cobol
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
identification division.
|
||||
program-id. string-append.
|
||||
|
||||
data division.
|
||||
working-storage section.
|
||||
01 some-string.
|
||||
05 elements pic x occurs 0 to 80 times depending on limiter.
|
||||
01 limiter usage index value 7.
|
||||
01 current usage index.
|
||||
|
||||
procedure division.
|
||||
append-main.
|
||||
|
||||
move "Hello, " to some-string
|
||||
|
||||
*> extend the limit and move using reference modification
|
||||
set current to length of some-string
|
||||
set limiter up by 5
|
||||
move "world" to some-string(current + 1:)
|
||||
display some-string
|
||||
|
||||
goback.
|
||||
end program string-append.
|
||||
5
Task/String-append/CoffeeScript/string-append-1.coffee
Normal file
5
Task/String-append/CoffeeScript/string-append-1.coffee
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a = "Hello, "
|
||||
b = "World!"
|
||||
c = a + b
|
||||
|
||||
console.log c
|
||||
1
Task/String-append/CoffeeScript/string-append-2.coffee
Normal file
1
Task/String-append/CoffeeScript/string-append-2.coffee
Normal file
|
|
@ -0,0 +1 @@
|
|||
console.log "Hello, ".concat "World!"
|
||||
11
Task/String-append/Kotlin/string-append.kotlin
Normal file
11
Task/String-append/Kotlin/string-append.kotlin
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fun main(args: Array<String>) {
|
||||
var s = "a"
|
||||
s += "b"
|
||||
s += "c"
|
||||
println(s)
|
||||
println("a" + "b" + "c")
|
||||
val a = "a"
|
||||
val b = "b"
|
||||
val c = "c"
|
||||
println("$a$b$c")
|
||||
}
|
||||
12
Task/String-append/Lua/string-append-1.lua
Normal file
12
Task/String-append/Lua/string-append-1.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function string:show ()
|
||||
print(self)
|
||||
end
|
||||
|
||||
function string:append (s)
|
||||
self = self .. s
|
||||
end
|
||||
|
||||
x = "Hi "
|
||||
x:show()
|
||||
x:append("there!")
|
||||
x:show()
|
||||
3
Task/String-append/Lua/string-append-2.lua
Normal file
3
Task/String-append/Lua/string-append-2.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
x = "Hi "
|
||||
x = x .. "there!"
|
||||
print(x)
|
||||
3
Task/String-append/Maple/string-append.maple
Normal file
3
Task/String-append/Maple/string-append.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a := "Hello";
|
||||
b := cat(a, " World");
|
||||
c := `||`(a, " World");
|
||||
4
Task/String-append/SNOBOL4/string-append.sno
Normal file
4
Task/String-append/SNOBOL4/string-append.sno
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
s = "Hello"
|
||||
s = s ", World!"
|
||||
OUTPUT = s
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue