Anonymous user
Copy a string: Difference between revisions
add string copy for BLC
mNo edit summary |
imported>Tromp (add string copy for BLC) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 636:
?(^same$+5) = ?(^source$+5)
PRINT same$</syntaxhighlight>
=={{header|Binary Lambda Calculus}}==
In BLC, every value is immutable, including byte-strings. So one never needs to copy them; references are shared.
=={{header|BQN}}==
Line 822 ⟶ 826:
=={{header|COBOL}}==
{{trans|C#}}
<syntaxhighlight lang="
MOVE src TO dst</syntaxhighlight>
Line 980 ⟶ 984:
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
a$ = "hello"
b$ = a$</syntaxhighlight>▼
b$ = a$
print b$
=={{header|EchoLisp}}==
Line 1,960 ⟶ 1,967:
=={{header|Pascal}}==
''See also: [[#Delphi|Delphi]]''
<syntaxhighlight lang="pascal" highlight="9,13,15">program
var▼
{ The Extended Pascal `string` schema data type
is essentially a `packed array[1..capacity] of char`. }
source, destination: string(80);
begin▼
source := 'Hello world!';
▲var
{ In Pascal _whole_ array data type values can be copied by assignment. }
destination := source;
{ Provided `source` is a _non-empty_ string value
you can copy in Extended Pascal sub-ranges _of_ _string_ types, too.
Note, the sub-range notation is not permitted for a `bindable` data type. }
▲begin
destination := source[1..length(source)];
{ You can also employ Extended Pascal’s `writeStr` routine: }
writeStr(destination, source);
▲end;</syntaxhighlight>
=={{header|Perl}}==
Line 2,634 ⟶ 2,629:
Although technically a reference type, this means there is no need to distinguish between copying the contents of a string and making an additional reference. We can therefore just use assignment to copy a string.
<syntaxhighlight lang="
var t = s
System.print("Are 's' and 't' equal? %(s == t)")</syntaxhighlight>
|