Copy a string: Difference between revisions

→‎{{header|R}}: Added REBOL example.
(pike)
(→‎{{header|R}}: Added REBOL example.)
Line 470:
<lang R>str1 <- "abc"
str2 <- str1</lang>
 
=={{header|REBOL}}==
<lang REBOL>REBOL [
Title: "String Copy"
Date: 2009-12-16
Author: oofoe
URL: http://rosettacode.org/wiki/Copy_a_string
]
 
x: y: "Testing."
y/2: #"X"
print ["Both variables reference same string:" mold x "," mold y]
 
x: "Slackeriffic!"
print ["Now reference different strings:" mold x "," mold y]
 
y: copy x ; String copy here!
y/3: #"X" ; Modify string.
print ["x copied to y, then modified:" mold x "," mold y]
 
y: copy/part x 7 ; Copy only the first part of y to x.
print ["Partial copy:" mold x "," mold y]
 
y: copy/part skip x 2 3
print ["Partial copy from offset:" mold x "," mold y]</lang>
 
Output:
 
<pre>Script: "String Copy" (16-Dec-2009)
Both variables reference same string: "TXsting." , "TXsting."
Now reference different strings: "Slackeriffic!" , "TXsting."
x copied to y, then modified: "Slackeriffic!" , "SlXckeriffic!"
Partial copy: "Slackeriffic!" , "Slacker"
Partial copy from offset: "Slackeriffic!" , "ack"</pre>
 
=={{header|Raven}}==
Anonymous user