Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,26 @@
USING: accessors arrays io kernel named-tuples prettyprint
sequences sequences.deep ;
! Define a simple class
TUPLE: foo bar baz ;
! Allow instances of foo to be modified like an array
INSTANCE: foo named-tuple
! Create a foo object composed of mutable objects
V{ 1 2 3 } V{ 4 5 6 } [ clone ] bi@ foo boa
! create a copy of the reference to the object
dup
! create a deep copy from this copy
>array [ clone ] deep-map T{ foo } like
! print them both
"Before modification:" print [ [ . ] bi@ ] 2keep nl
! modify the deep copy
[ -1 suffix! ] change-bar
! print them both again
"After modification:" print [ . ] bi@

View file

@ -0,0 +1,16 @@
! Create a foo object composed of mutable objects
V{ 1 2 3 } V{ 4 5 6 } [ clone ] bi@ foo boa
! create a copy of the reference to the object
dup
! create a deep copy from this copy
object>bytes bytes>object
! print them both
"Before modification:" print [ [ . ] bi@ ] 2keep nl
! modify the deep copy
[ -99 suffix! ] change-bar
"After modification:" print [ . ] bi@