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

40 lines
796 B
Plaintext

# Converts list to string
fun -string !ltos -list &inlist
getlistsize *inlist &listlen
set &idx 0
set &ans ""
add $ans "[" &ans
@stdoutloop
getlistat *inlist $idx &store
tostring $store &store
add $ans $store &ans
add $idx 1 &idx
equal $idx $listlen &store
if $store %end
add $ans ", " &ans
jump %stdoutloop
@end
add $ans "]" &ans
return $ans
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
endfun