Files
ground-programs/packages/lists/lists.grnd

40 lines
796 B
Plaintext
Raw Normal View History

2025-09-13 10:10:21 +10:00
# Converts list to string
fun -string !ltos -list &inlist
getlistsize *inlist &listlen
set &idx 0
set &ans ""
2025-09-18 19:57:24 +10:00
add $ans "[" &ans
2025-09-13 10:10:21 +10:00
@stdoutloop
getlistat *inlist $idx &store
2025-09-18 19:57:24 +10:00
tostring $store &store
2025-09-13 10:10:21 +10:00
add $ans $store &ans
add $idx 1 &idx
equal $idx $listlen &store
2025-09-19 19:37:43 +10:00
if $store %end
2025-09-13 10:10:21 +10:00
add $ans ", " &ans
jump %stdoutloop
2025-09-19 19:37:43 +10:00
@end
2025-09-13 10:10:21 +10:00
add $ans "]" &ans
return $ans
2025-09-19 19:37:43 +10:00
endfun
fun -list !listremove -list &input
set &idx 0
getlistsize *input &endidx
subtract $endidx 1 &endidx
setlist *ans
@loop
equal $idx $endidx &store
if $store %return
getlistat *input $idx &store
listappend *ans $store
add $idx 1 &idx
jump %loop
@return
return *ans
2025-09-18 19:57:24 +10:00
endfun