Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,7 @@
---
category:
- String manipulation
- Simple
- Strings
from: http://rosettacode.org/wiki/Copy_a_string
note: Basic language learning

View file

@ -0,0 +1,11 @@
This task is about copying a string.
;Task:
Where it is relevant, distinguish between copying the contents of a string
versus making an additional reference to an existing string.
{{Template:Strings}}
<br><br>

View file

@ -0,0 +1,2 @@
V src = hello
V dst = copy(src)

View file

@ -0,0 +1,17 @@
* Duplicate a string
MVC A,=CL64'Hello' a='Hello'
MVC B,A b=a memory copy
MVC A,=CL64'Goodbye' a='Goodbye'
XPRNT A,L'A print a
XPRNT B,L'B print b
...
* Make reference to a string a string
MVC A,=CL64'Hi!' a='Hi!'
LA R1,A r1=@a set pointer
ST R1,REFA refa=@a store pointer
XPRNT A,L'A print a
XPRNT 0(R1),L'A print %refa
...
A DS CL64 a
B DS CL64 b
REFA DS A @a

View file

@ -0,0 +1,35 @@
source equ $10 ;$10 was chosen arbitrarily
source_hi equ source+1 ;the high byte MUST be after the low byte, otherwise this will not work.
dest equ $12
dest_hi equ dest+1
LDA #<MyString ;get the low byte of &MyString
STA source
LDA #>MyString ;get the high byte
STA source_hi ;we just created a "shallow reference" to an existing string.
;As it turns out, this is a necessary step to do a deep copy.
LDA #<RamBuffer
STA dest
LDA #>RamBuffer
STA dest_hi
strcpy:
;assumes that RamBuffer is big enough to hold the source string, and that the memory ranges do not overlap.
;if you've ever wondered why C's strcpy is considered "unsafe", this is why.
LDY #0
.again:
LDA (source),y
STA (dest),y
BEQ .done
INY
BNE .again ;exit after 256 bytes copied or the null terminator is reached, whichever occurs first.
RTS
MyString:
byte "hello",0
RamBuffer:
byte 0,0,0,0,0,0

View file

@ -0,0 +1,4 @@
myString: DC.B "HELLO WORLD",0
EVEN
LEA myString,A3

View file

@ -0,0 +1,16 @@
StringRam equ $100000
myString: DC.B "HELLO WORLD",0
EVEN
LEA myString,A3
LEA StringRam,A4
CopyString:
MOVE.B (A3)+,D0
MOVE.B D0,(A4)+ ;we could have used "MOVE.B (A3)+,(A4)+" but this makes it easier to check for the terminator.
BEQ Terminated
BRA CopyString
Terminated: ;the null terminator is already stored along with the string itself, so we are done.
;program ends here.

View file

@ -0,0 +1,20 @@
.model small
.stack 1024
.data
myString byte "Hello World!",0 ; a null-terminated string
myStruct word 0
.code
mov ax,@data
mov ds,ax ;load data segment into DS
mov bx,offset myString ;get the pointer to myString
mov word ptr [ds:myStruct],bx
mov ax,4C00h
int 21h ;quit program and return to DOS

View file

@ -0,0 +1,28 @@
.model small
.stack 1024
.data
myString byte "Hello World!",0 ; a null-terminated string
StringRam byte 256 dup (0) ;256 null bytes
.code
mov ax,@data
mov ds,ax ;load data segment into DS
mov es,ax ;also load it into ES
mov si,offset myString
mov di,offset StringRam
mov cx,12 ;length of myString
cld ;make MOVSB auto-increment rather than auto-decrement (I'm pretty sure DOS begins with
;the direction flag cleared but just to be safe)
rep movsb ;copies 12 bytes from [ds:si] to [es:di]
mov al,0 ;create a null terminator
stosb ;store at the end. (It's already there since we initialized StringRam to zeroes, but you may need to do this depending
;on what was previously stored in StringRam, if you've copied a string there already.
mov ax,4C00h
int 21h ;quit program and return to DOS

View file

@ -0,0 +1,62 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program copystr64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*******************************************/
/* Initialized data */
/*******************************************/
.data
szString: .asciz "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
/*******************************************/
/* UnInitialized data */
/*******************************************/
.bss
.align 4
qPtString: .skip 8
szString1: .skip 80
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main: // entry of program
// display start string
ldr x0,qAdrszString
bl affichageMess
// copy pointer string
ldr x0,qAdrszString
ldr x1,qAdriPtString
str x0,[x1]
// control
ldr x1,qAdriPtString
ldr x0,[x1]
bl affichageMess
// copy string
ldr x0,qAdrszString
ldr x1,qAdrszString1
1:
ldrb w2,[x0],1 // read one byte and increment pointer one byte
strb w2,[x1],1 // store one byte and increment pointer one byte
cmp x2,#0 // end of string ?
bne 1b // no -> loop
// control
ldr x0,qAdrszString1
bl affichageMess
100: // standard end of the program */
mov x0,0 // return code
mov x8,EXIT // request to exit program
svc 0 // perform the system call
qAdrszString: .quad szString
qAdriPtString: .quad qPtString
qAdrszString1: .quad szString1
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,3 @@
data: lv_string1 type string value 'Test',
lv_string2 type string.
lv_string2 = lv_string1.

View file

@ -0,0 +1,2 @@
DATA(string1) = |Test|.
DATA(string2) = string1.

View file

@ -0,0 +1,4 @@
(
STRING src:="Hello", dest;
dest:=src
)

View file

@ -0,0 +1,9 @@
begin
% strings are (fixed length) values in algol W. Assignment makes a copy %
string(10) a, copyOfA;
a := "some text";
copyOfA := a;
% assignment to a will not change copyOfA %
a := "new value";
write( a, copyOfA )
end.

View file

@ -0,0 +1,76 @@
/* ARM assembly Raspberry PI */
/* program copystr.s */
/* Constantes */
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
/* Initialized data */
.data
szString: .asciz "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n"
/* UnInitialized data */
.bss
.align 4
iPtString: .skip 4
szString1: .skip 80
/* code section */
.text
.global main
main: /* entry of program */
push {fp,lr} /* saves 2 registers */
@ display start string
ldr r0,iAdrszString
bl affichageMess
@ copy pointer string
ldr r0,iAdrszString
ldr r1,iAdriPtString
str r0,[r1]
@ control
ldr r1,iAdriPtString
ldr r0,[r1]
bl affichageMess
@ copy string
ldr r0,iAdrszString
ldr r1,iAdrszString1
1:
ldrb r2,[r0],#1 @ read one byte and increment pointer one byte
strb r2,[r1],#1 @ store one byte and increment pointer one byte
cmp r2,#0 @ end of string ?
bne 1b @ no -> loop
@ control
ldr r0,iAdrszString1
bl affichageMess
100: /* standard end of the program */
mov r0, #0 @ return code
pop {fp,lr} @restaur 2 registers
mov r7, #EXIT @ request to exit program
swi 0 @ perform the system call
iAdrszString: .int szString
iAdriPtString: .int iPtString
iAdrszString1: .int szString1
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {fp,lr} /* save registres */
push {r0,r1,r2,r7} /* save others registers */
mov r2,#0 /* counter length */
1: /* loop length calculation */
ldrb r1,[r0,r2] /* read octet start position + index */
cmp r1,#0 /* if 0 its over */
addne r2,r2,#1 /* else add 1 in the length */
bne 1b /* and loop */
/* so here r2 contains the length of the message */
mov r1,r0 /* address message in r1 */
mov r0,#STDOUT /* code to write to the standard output Linux */
mov r7, #WRITE /* code call system "write" */
swi #0 /* call systeme */
pop {r0,r1,r2,r7} /* restaur others registers */
pop {fp,lr} /* restaur des 2 registres */
bx lr /* return */

View file

@ -0,0 +1,6 @@
BEGIN {
a = "a string"
b = a
sub(/a/, "X", a) # modify a
print b # b is a copy, not a reference to...
}

View file

@ -0,0 +1,18 @@
PROC Main()
CHAR ARRAY str1,str2,str3(10)
str1="Atari"
str2=str1
SCopy(str3,str1)
PrintF(" base=%S%E",str1)
PrintF("alias=%S%E",str2)
PrintF(" copy=%S%E",str3)
PutE()
SCopy(str1,"Action!")
PrintF(" base=%S%E",str1)
PrintF("alias=%S%E",str2)
PrintF(" copy=%S%E",str3)
RETURN

View file

@ -0,0 +1,2 @@
var str1:String = "Hello";
var str2:String = str1;

View file

@ -0,0 +1,2 @@
Src : String := "Hello";
Dest : String := Src;

View file

@ -0,0 +1,3 @@
Src : String := "Rosetta Stone";
Dest : String := Src(1..7); -- Assigns "Rosetta" to Dest
Dest2 : String := Src(9..13); -- Assigns "Stone" to Dest2

View file

@ -0,0 +1,6 @@
-- Instantiate the generic package Ada.Strings.Bounded.Generic_Bounded_Length with a maximum length of 80 characters
package Flexible_String is new Ada.Strings.Bounded.Generic_Bounded_Length(80);
use Flexible_String;
Src : Bounded_String := To_Bounded_String("Hello");
Dest : Bounded_String := Src;

View file

@ -0,0 +1,3 @@
-- The package Ada.Strings.Unbounded contains the definition of the Unbounded_String type and all its methods
Src : Unbounded_String := To_Unbounded_String("Hello");
Dest : Unbounded_String := Src;

View file

@ -0,0 +1,3 @@
text s, t;
t = "Rosetta";
s = t;

View file

@ -0,0 +1,7 @@
data s, t;
# Copy -t- into -s-
b_copy(s, t);
# Set -s- as a reference of the object -t- is pointing
b_set(s, t);
# or:
s = t;

View file

@ -0,0 +1,6 @@
#include <hopper.h>
main:
s = "string to copy"
t = s
{s,"\n",t}println
exit(0)

View file

@ -0,0 +1,6 @@
#include <hopper.h>
main:
s=""
{"1:","string to copy"},cpy(s),println
{"2:",s}println
exit(0)

View file

@ -0,0 +1,6 @@
#include <hopper.h>
main:
s=""
{"string to copy"},mov(s)
{s}println
exit(0)

View file

@ -0,0 +1,6 @@
String original = 'Test';
String cloned = original;
//"original == cloned" is true
cloned += ' more';
//"original == cloned" is false

View file

@ -0,0 +1,2 @@
set src to "Hello"
set dst to src

View file

@ -0,0 +1,4 @@
100 DEF FN P(A) = PEEK (A) + PEEK(A + 1) * 256 : FOR I = FN P(105) TO FN P(107) - 1 STEP 7 : ON PEEK(I + 1) < 128 OR PEEK(I) > 127 GOTO 130 : ON LEFT$(P$, 1) <> CHR$(PEEK(I)) GOTO 130
110 IF LEN(P$) > 1 THEN ON PEEK(I + 1) = 128 GOTO 130 : IF MID$(P$, 2, 1) <> CHR$(PEEK(I + 1) - 128) GOTO 130
120 POKE I + 4, P / 256 : POKE I + 3, P - PEEK(I + 4) * 256 : RETURN
130 NEXT I : STOP

View file

@ -0,0 +1,2 @@
S$ = "HELLO" : REM S$ IS THE ORIGINAL STRING
C$ = S$ : REM C$ IS THE COPY

View file

@ -0,0 +1,3 @@
P$ = "S" : P = 53637 : GOSUB 100"POINT STRING S AT SOMETHING ELSE
?S$
?C$

View file

@ -0,0 +1,19 @@
a: new "Hello"
b: a ; reference the same string
; changing one string in-place
; will change both strings
'b ++ "World"
print b
print a
c: "Hello"
d: new c ; make a copy of the older string
; changing one string in-place
; will change only the string in question
'd ++ "World"
print d
print c

View file

@ -0,0 +1,5 @@
string src, dst;
src = "Hello";
dst = src;
src = " world...";
write(dst, src);

View file

@ -0,0 +1,2 @@
src := "Hello"
dst := src

View file

@ -0,0 +1,2 @@
$Src= "Hello"
$dest = $Src

View file

@ -0,0 +1,10 @@
Lbl STRCPY
r₁→S
While {r₂}
{r₂}→{r₁}
r₁++
r₂++
End
0→{r₁}
S
Return

View file

@ -0,0 +1,4 @@
src$ = "Hello"
dst$ = src$
src$ = " world..."
print dst$; src$

View file

@ -0,0 +1,11 @@
source$ = "Hello, world!"
REM Copy the contents of a string:
copy$ = source$
PRINT copy$
REM Make an additional reference to a string:
!^same$ = !^source$
?(^same$+4) = ?(^source$+4)
?(^same$+5) = ?(^source$+5)
PRINT same$

View file

@ -0,0 +1,5 @@
a "Hello"
b a
•Show ab
a "hi"
•Show ab

View file

@ -0,0 +1,2 @@
"Hello" "Hello"
"hi" "Hello"

View file

@ -0,0 +1,4 @@
a$ = "I am here"
b$ = a$
a$ = "Hello world..."
PRINT a$, b$

View file

@ -0,0 +1,5 @@
a$ = "Hello world..."
LOCAL b TYPE STRING
b = a$
a$ = "Goodbye..."
PRINT a$, b

View file

@ -0,0 +1,4 @@
babel> "Hello, world\n" dup cp dup 0 "Y" 0 1 move8
babel> << <<
Yello, world
Hello, world

View file

@ -0,0 +1,2 @@
set src=Hello
set dst=%src%

View file

@ -0,0 +1,8 @@
abcdef:?a;
!a:?b;
c=abcdef;
!c:?d;
!a:!b { variables a and b are the same and probably referencing the same string }
!a:!d { variables a and d are also the same but not referencing the same string }

View file

@ -0,0 +1,10 @@
#include <iostream>
#include <string>
int main( ) {
std::string original ("This is the original");
std::string my_copy = original;
std::cout << "This is the copy: " << my_copy << std::endl;
original = "Now we change the original! ";
std::cout << "my_copy still is " << my_copy << std::endl;
}

View file

@ -0,0 +1,2 @@
string src = "Hello";
string dst = src;

View file

@ -0,0 +1,60 @@
#include <stdlib.h> /* exit(), free() */
#include <stdio.h> /* fputs(), perror(), printf() */
#include <string.h>
int
main()
{
size_t len;
char src[] = "Hello";
char dst1[80], dst2[80];
char *dst3, *ref;
/*
* Option 1. Use strcpy() from <string.h>.
*
* DANGER! strcpy() can overflow the destination buffer.
* strcpy() is only safe if the source string is shorter than
* the destination buffer. We know that "Hello" (6 characters
* with the final '\0') easily fits in dst1 (80 characters).
*/
strcpy(dst1, src);
/*
* Option 2. Use strlen() and memcpy() from <string.h>, to copy
* strlen(src) + 1 bytes including the final '\0'.
*/
len = strlen(src);
if (len >= sizeof dst2) {
fputs("The buffer is too small!\n", stderr);
exit(1);
}
memcpy(dst2, src, len + 1);
/*
* Option 3. Use strdup() from <string.h>, to allocate a copy.
*/
dst3 = strdup(src);
if (dst3 == NULL) {
/* Failed to allocate memory! */
perror("strdup");
exit(1);
}
/* Create another reference to the source string. */
ref = src;
/* Modify the source string, not its copies. */
memset(src, '-', 5);
printf(" src: %s\n", src); /* src: ----- */
printf("dst1: %s\n", dst1); /* dst1: Hello */
printf("dst2: %s\n", dst2); /* dst2: Hello */
printf("dst3: %s\n", dst3); /* dst3: Hello */
printf(" ref: %s\n", ref); /* ref: ----- */
/* Free memory from strdup(). */
free(dst3);
return 0;
}

View file

@ -0,0 +1,22 @@
#include <stdlib.h> /* exit() */
#include <stdio.h> /* fputs(), printf() */
#include <string.h>
int
main()
{
char src[] = "Hello";
char dst[80];
/* Use strlcpy() from <string.h>. */
if (strlcpy(dst, src, sizeof dst) >= sizeof dst) {
fputs("The buffer is too small!\n", stderr);
exit(1);
}
memset(src, '-', 5);
printf("src: %s\n", src); /* src: ----- */
printf("dst: %s\n", dst); /* dst: Hello */
return 0;
}

View file

@ -0,0 +1,23 @@
#include <gadget/gadget.h>
LIB_GADGET_START
Main
String v, w = "this message is a message";
Let( v, "Hello world!");
Print "v = %s\nw = %s\n\n", v,w;
Get_fn_let( v, Upper(w) );
Print "v = %s\nw = %s\n\n", v,w;
Stack{
Store ( v, Str_tran_last( Upper(w), "MESSAGE", "PROOF" ) );
}Stack_off;
Print "v = %s\nw = %s\n\n", v,w;
Free secure v, w;
End

View file

@ -0,0 +1,2 @@
MOVE "Hello" TO src
MOVE src TO dst

View file

@ -0,0 +1,3 @@
(let [s "hello"
s1 s]
(println s s1))

View file

@ -0,0 +1,2 @@
<cfset stringOrig = "I am a string." />
<cfset stringCopy = stringOrig />

View file

@ -0,0 +1,7 @@
10 A$ = "HELLO"
20 REM COPY CONTENTS OF A$ TO B$
30 B$ = A$
40 REM CHANGE CONTENTS OF A$
50 A$ = "HI"
60 REM DISPLAY CONTENTS
70 PRINT A$, B$

View file

@ -0,0 +1,10 @@
(let* ((s1 "Hello") ; s1 is a variable containing a string
(s1-ref s1) ; another variable with the same value
(s2 (copy-seq s1))) ; s2 has a distinct string object with the same contents
(assert (eq s1 s1-ref)) ; same object
(assert (not (eq s1 s2))) ; different object
(assert (equal s1 s2)) ; same contents
(fill s2 #\!) ; overwrite s2
(princ s1)
(princ s2)) ; will print "Hello!!!!!"

View file

@ -0,0 +1,4 @@
VAR
str1: ARRAY 128 OF CHAR;
str2: ARRAY 32 OF CHAR;
str3: ARRAY 25 OF CHAR;

View file

@ -0,0 +1,4 @@
str1 := "abcdefghijklmnopqrstuvwxyz";
str3 := str1; (* don't compile, incompatible assignement *)
str3 := str1$; (* runtime error, string too long *)
str2 := str1$; (* OK *)

View file

@ -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:

View file

@ -0,0 +1,2 @@
s1 = "Hello"
s2 = s1

View file

@ -0,0 +1,12 @@
void main() {
string src = "This is a string";
// copy contents:
auto dest1 = src.idup;
// copy contents to mutable char array
auto dest2 = src.dup;
// copy just the fat reference of the string
auto dest3 = src;
}

View file

@ -0,0 +1,3 @@
[a string] # push "a string" on the main stack
d # duplicate the top value
f # show the current contents of the main stack

View file

@ -0,0 +1,15 @@
program CopyString;
{$APPTYPE CONSOLE}
var
s1: string;
s2: string;
begin
s1 := 'Goodbye';
s2 := s1; // S2 points at the same string as S1
s2 := s2 + ', World!'; // A new string is created for S2
Writeln(s1);
Writeln(s2);
end.

View file

@ -0,0 +1,2 @@
var src = "foobar"
var dst = src

View file

@ -0,0 +1,63 @@
[ Copy a string
=============
A program for the EDSAC
Copies the source string into storage
tank 6, which is assumed to be free,
and then prints it from there
Works with Initial Orders 2 ]
T56K
GK
[ 0 ] A34@ [ copy the string ]
[ 1 ] T192F
[ 2 ] H34@
C32@
S32@
E17@
T31@
A@
A33@
T@
A1@
A33@
T1@
A2@
A33@
T2@
E@
[ 17 ] O192F [ print the copy ]
[ 18 ] H192F
C32@
S32@
E30@
T31@
A17@
A33@
T17@
A18@
A33@
T18@
E17@
[ 30 ] ZF
[ 31 ] PF
[ 32 ] PD
[ 33 ] P1F
[ 34 ] *F
RF
OF
SF
EF
TF
TF
AF
!F
CF
OF
DF
ED
EZPF

View file

@ -0,0 +1,11 @@
text original = "Yellow world"
text ref = original # copying the reference
text copied = *original # copying the content
original[0] = "H" # texts are indexable and mutable
original[5] = ","
ref.append("!") # texts are coercible and growable
copied += "?"
^|
| original == ref == "Hello, world!"
| copied == "Yellow world?"
|^

View file

@ -0,0 +1,2 @@
a$ = "hello"
b$ = a$

View 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

View file

@ -0,0 +1,3 @@
var src := "Hello";
var dst := src; // copying the reference
var copy := src.clone(); // copying the content

View file

@ -0,0 +1,2 @@
src = "Hello"
dst = src

View file

@ -0,0 +1,7 @@
(let* ((str1 "hi")
(str1-ref str1)
(str2 (copy-sequence str1)))
(eq str1 str1-ref) ;=> t
(eq str1 str2) ;=> nil
(equal str1 str1-ref) ;=> t
(equal str1 str2)) ;=> t

View file

@ -0,0 +1,2 @@
Src = "Hello".
Dst = Src.

View file

@ -0,0 +1,2 @@
sequence first = "ABC"
sequence newOne = first

View file

@ -0,0 +1,6 @@
let str = "hello"
let additionalReference = str
let deepCopy = System.String.Copy( str )
printfn "%b" <| System.Object.ReferenceEquals( str, additionalReference ) // prints true
printfn "%b" <| System.Object.ReferenceEquals( str, deepCopy ) // prints false

View file

@ -0,0 +1,4 @@
"This is a mutable string." dup ! reference
"Let's make a deal!" dup clone ! copy
"New" " string" append . ! new string
"New string"

View file

@ -0,0 +1,2 @@
SBUF" Grow me!" dup " OK." append
SBUF" Grow me! OK."

View file

@ -0,0 +1,2 @@
SBUF" I'll be a string someday." >string .
"I'll be a string someday."

View file

@ -0,0 +1,9 @@
\ Allocate two string buffers
create stringa 256 allot
create stringb 256 allot
\ Copy a constant string into a string buffer
s" Hello" stringa place
\ Copy the contents of one string buffer into another
stringa count stringb place

View file

@ -0,0 +1 @@
str2 = str1

View 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

View file

@ -0,0 +1,2 @@
a = "Monkey"
b = a

View file

@ -0,0 +1,10 @@
include "NSLog.incl"
CFStringRef original, copy
original = @"Hello!"
copy = fn StringWithString( original )
NSLog( @"%@", copy )
HandleEvents

View file

@ -0,0 +1,13 @@
#In GAP strings are lists of characters. An affectation simply copy references
a := "more";
b := a;
b{[1..4]} := "less";
a;
# "less"
# Here is a true copy
a := "more";
b := ShallowCopy(a);
b{[1..4]} := "less";
a;
# "more"

View file

@ -0,0 +1,2 @@
src = "string";
dest = src;

View file

@ -0,0 +1,3 @@
Start.Programs,Accessories,Notepad,
Type:Hello world[pling],Highlight:Hello world[pling],
Menu,Edit,Copy,Menu,Edit,Paste

View file

@ -0,0 +1,10 @@
Public Sub main()
Dim src As String
Dim dst As String
src = "Hello"
dst = src
Print src
Print dst
End

View file

@ -0,0 +1,2 @@
src := "Hello"
dst := src

View file

@ -0,0 +1,22 @@
package main
import "fmt"
func main() {
// creature string
var creature string = "shark"
// point to creature
var pointer *string = &creature
// creature string
fmt.Println("creature =", creature) // creature = shark
// creature location in memory
fmt.Println("pointer =", pointer) // pointer = 0xc000010210
// creature through the pointer
fmt.Println("*pointer =", *pointer) // *pointer = shark
// set creature through the pointer
*pointer = "jellyfish"
// creature through the pointer
fmt.Println("*pointer =", *pointer) // *pointer = jellyfish
// creature string
fmt.Println("creature =", creature) // creature = jellyfish
}

View file

@ -0,0 +1,3 @@
def string = 'Scooby-doo-bee-doo' // assigns string object to a variable reference
def stringRef = string // assigns another variable reference to the same object
def stringCopy = new String(string) // copies string value into a new object, and assigns to a third variable reference

View file

@ -0,0 +1,4 @@
assert string == stringRef // they have equal values (like Java equals(), not like Java ==)
assert string.is(stringRef) // they are references to the same objext (like Java ==)
assert string == stringCopy // they have equal values
assert ! string.is(stringCopy) // they are references to different objects (like Java !=)

View file

@ -0,0 +1,2 @@
cSource := "Hello World"
cDestination := cSource

View file

@ -0,0 +1,2 @@
src = "Hello World"
dst = src

View file

@ -0,0 +1,10 @@
//Strings are immutable in 'i'.
software {
a = "Hello World"
b = a //This copies the string.
a += "s"
print(a)
print(b)
}

View file

@ -0,0 +1,6 @@
procedure main()
a := "qwerty"
b := a
b[2+:4] := "uarterl"
write(a," -> ",b)
end

View file

@ -0,0 +1,2 @@
src =: 'hello'
dest =: src

View file

@ -0,0 +1,7 @@
String src = "Hello";
String newAlias = src;
String strCopy = new String(src);
//"newAlias == src" is true
//"strCopy == src" is false
//"strCopy.equals(src)" is true

View file

@ -0,0 +1 @@
StringBuffer srcCopy = new StringBuffer("Hello");

View file

@ -0,0 +1,4 @@
var container = {myString: "Hello"};
var containerCopy = container; // Now both identifiers refer to the same object
containerCopy.myString = "Goodbye"; // container.myString will also return "Goodbye"

View file

@ -0,0 +1,4 @@
var a = "Hello";
var b = a; // Same as saying window.b = window.a
b = "Goodbye" // b contains a copy of a's value and a will still return "Hello"

View file

@ -0,0 +1 @@
"hello" dup

Some files were not shown because too many files have changed in this diff Show more