Copy a string: Difference between revisions
Add ed example
m (→{{header|Wren}}: Changed to Wren S/H) |
(Add ed example) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 575:
src$ = " world..."
PRINT dst$; src$</syntaxhighlight>
==={{header|SmallBASIC}}===
src = "Hello"
dst = src
src = " world..."
PRINT dst; src
==={{header|True BASIC}}===
Line 636 ⟶ 645:
?(^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 995 ⟶ 1,008:
t → "abc"
(eq? s t) → #t ;; same reference, same object
</syntaxhighlight>
=={{header|Ed}}==
Copies the current buffer contents in its entirety.
<syntaxhighlight>
,t
</syntaxhighlight>
Line 1,963 ⟶ 1,984:
=={{header|Pascal}}==
''See also: [[#Delphi|Delphi]]''
<syntaxhighlight lang="pascal" highlight="9,13,15">program copyAString;
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!';
{ 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. }
destination := source[1..length(source)];
{ You can also employ Extended Pascal’s `writeStr` routine: }
writeStr(destination, source);
end.</syntaxhighlight>
=={{header|PascalABC.NET}}==
▲<syntaxhighlight lang="pascal">program in,out;
Strings in PascalABC.NET are references.
<syntaxhighlight lang="pascal" highlight="9,13,15">
▲var
s1,s2 : string ;▼
begin
var
end.
</syntaxhighlight>
▲end;</syntaxhighlight>
=={{header|Perl}}==
|