- Lists can contain a mixture of data types: numbers, strings and sub-lists (which themselves can have sub-sub-lists etc).
- Lists don't have to be statically declared in advance, they can grow and shrink dynamically.
As a proof-of-principle I have written a tiny proto-library which has some of the most basic functionality needed: it can create a list, it can append elements to the list, and it can return elements from the list. Here is an example of what it can already do:
Code: Select all
REM Create a new (empty) list:
PROC_listcreate(mylist())
REM Append a number and a string to the list:
PROC_listappend(mylist(), PI)
PROC_listappend(mylist(), FN_sv("A string"))
REM Note that the list length is now two:
PRINT "Number of elements = "; FN_listlen(mylist())
REM Create another list, but this time as an initialised list:
DIM child(1)
child() = FN_sv("Hello "), FN_sv("world!")
REM Append the 'child' list to the parent list:
PROC_listappend(mylist(), FN_lv(child()))
REM Note that the list length is now three:
PRINT "Number of elements = "; FN_listlen(mylist())
REM Print the first two elements of the parent list:
PRINT mylist(0) TAB(15) FN_vs(mylist(1))
REM Extract the third element:
PROC_vl(mylist(2), temp())
REM Print the contents of that list:
PRINT FN_vs(temp(0)) FN_vs(temp(1))
REM Clean up and free memory:
PROC_listdiscard(mylist())
END
Code: Select all
Number of elements = 2
Number of elements = 3
3.14159265 A string
Hello world!