Lists package

This commit is contained in:
2025-09-18 19:57:24 +10:00
parent b625bc6244
commit 5f65c1b42b
2 changed files with 14 additions and 8 deletions

View File

@@ -3,9 +3,10 @@ fun -string !ltos -list &inlist
getlistsize *inlist &listlen getlistsize *inlist &listlen
set &idx 0 set &idx 0
set &ans "" set &ans ""
add $ans '[' &ans add $ans "[" &ans
@stdoutloop @stdoutloop
getlistat *inlist $idx &store getlistat *inlist $idx &store
tostring $store &store
add $ans $store &ans add $ans $store &ans
add $idx 1 &idx add $idx 1 &idx
equal $idx $listlen &store equal $idx $listlen &store
@@ -17,8 +18,3 @@ fun -string !ltos -list &inlist
add $ans "]" &ans add $ans "]" &ans
return $ans return $ans
endfun endfun
setlist *store 4 2 "Hello"
pusharg *store
call !ltos &store
stdlnout $store

View File

@@ -1 +1,11 @@
### Due to the current limitations of ground, this package is not ready for use. # Lists library
This library adds extra list manipulation functions to ground. It is entirely coded in ground.
Please note that you cannot copy a single function from the package, as some functions rely on other functions in the library (reliance on other functions is detailed below).
## Functions
### fun -string !ltos -list &inlist
Converts a list to a string, in the format [$item1, $item2, $item3, ...] (no prerequisites).