From 2f5b1f40b122839991a5550cadf0c2d3f90815ae Mon Sep 17 00:00:00 2001 From: IgorCielniak Date: Tue, 10 Feb 2026 11:31:39 +0100 Subject: [PATCH] added a function to convert the buildt in array to a dynamic array --- stdlib/arr.sl | 10 +++++++++- stdlib/mem.sl | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stdlib/arr.sl b/stdlib/arr.sl index c33432c..5ac29e6 100644 --- a/stdlib/arr.sl +++ b/stdlib/arr.sl @@ -11,6 +11,14 @@ import mem.sl +#arr_to_dyn [* | std_arr] -> [* | dyn_arr] +word arr_to_dyn + dup @ dup dup 3 + alloc dup rot ! + dup rot 2 * swap 8 + swap ! dup 16 + + dup 8 + dup -rot ! 0 swap 3 pick dup @ + 8 * swap 8 + swap memcpy 2drop drop nip +end + #arr_new [* | cap] -> [* | arr] # Create a new array with given initial capacity (minimum 1) word arr_new @@ -117,4 +125,4 @@ end # Set element at index i to x word arr_set arr_data swap 8 * + swap ! -end +end \ No newline at end of file diff --git a/stdlib/mem.sl b/stdlib/mem.sl index 05a1b88..51dafc5 100644 --- a/stdlib/mem.sl +++ b/stdlib/mem.sl @@ -55,7 +55,7 @@ end #memdump [*, len | addr] -> [* | addr] word memdump for - dup c@ puti cr 1 + + dup @ puti cr 8 + end end