Re: 2.6 feature request: foreach (off topic)
- Posted by "Juergen Luethje" <j.lue at gmx.de> Jul 15, 2005
- 418 views
Vincent wrote: > Robert Craig wrote: >> >> Vincent wrote: <snip> > I would also like to point out that that besides dynamic linked lists.. > there are 3 other methods to store data: Arrays, Structures, and Data > Sections. What does that mean in practice? When I want to dynamically append elements to an array in PureBASIC, then I'm supposed to copy all my data to a linked list first? And when I then want to access elements *directly* without having to "walk through" the linked list from the beginning, then I have to copy my data back to an array? <snip> >> They of course have (inflexible) arrays: >> >> "Once an array is 'sized' it can be resized >> but its content will be deleted" >> (ouch!) >> > > Yea I didnt like that, but you can copy the contents into a temp > structure or linked list, then once it's resized, paste the values back > in. Well, "happy copying" ... Simple, elegant, and fast, eh? > Dynamic arrays in PB can have infinite dimentions, arrays in some > other basics are limited to 2 or 3 dimentions. There are more advantages of sequences over BASIC arrays. a) A sequence can hold elements of different data types in the same dimension: s = {"Hello world!", 5, -12.547} I don't think that this is possible with an array in any BASIC flavour. b) A "2-dimensional sequence" in Euphoria could look like this: s = { {1}, {7,8,12,-3,12}, {9,5} } AFAIK storing these data in a BASIC array would look something like this: a = { {1,0, 0, 0, 0}, {7,8,12,-3,12}, {9,5, 0, 0, 0} } IOW, there will have to be several additional elements with value 0 or something, wich are not needed at all, but which waste space of course. <snip> Regards, Juergen