Linked List Code

Nonsanity form at nonsanity.com
Wed Apr 27 17:10:18 EDT 2011


Ah, yes multi-dimensional arrays are fully supported by LC.

put "ABC" into myMDArray[ 1 ][ 3 ][ 2 ]

LC allows for nexting arrays, so basically this is an array of arrays of
values, or a three dimensional array.

 ~ Chris Innanen
 ~ Nonsanity


On Wed, Apr 27, 2011 at 3:20 PM, Pete <pete at mollysrevenge.com> wrote:

> I think maybe I used the wrong term.  I see how the comma-delimited list
> would work for a one-dimensional list but I need a multi-dimensional list -
> still not sure if I have the right terminology, maybe "multi-level" would
> be
> better
>
> To use your example, starting off with A,B,C,D,E,F I need to be able to
> branch off from item A to A1,A2,A3, etc and any or all of A1,A2,A3 might
> need to branch off again, and so on.
>
> I guess LC arrays would work for this with each level being a subkey of the
> key above it.
>
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
>
>
>
>
> On Wed, Apr 27, 2011 at 11:45 AM, Nonsanity <form at nonsanity.com> wrote:
>
> > Linked lists use pointers to allow the memory for the items to be
> allocated
> > as needed, and ties those pointers to each item for the next (and
> previous
> > for doubly-linked) so traversal code can hop from memory pocket to memory
> > pocket in the right order.
> >
> > Whereas an array in a language like C keeps all the items in sequential
> > memory locations so moving form one to the next is just a matter of
> adding
> > one to the pointer to the current item.
> >
> > In LiveCode, memory allocation and management is handled by the system.
> >
> > The old-school method of handling lists (and one I still use when order
> is
> > most important) is the good old comma-delimited list. Inserting and
> > deleting
> > is done with the "put x before/after" command or the "delete item x"
> > command. Access it direct by item number.
> >
> > put "A,B,C,D,E,F" into myList
> > delete item 5 of myList
> > put ",3" after item 2 of myList
> > put item 4 of myList into msg       -- "C"
> > put item 2 to -2 of myList into msg      -- "B,3,C,D"
> > put myList into msg         -- "A,B,3,C,D,F"
> >
> > You can also use arrays, though if you are deleting items, you need to
> > access the list of keys. This can get more complex, since LC's arrays are
> > actually maps.
> >
> >  ~ Chris Innanen
> >  ~ Nonsanity
> >
> >
> > On Sun, Apr 24, 2011 at 8:08 PM, Pete <pete at mollysrevenge.com> wrote:
> >
> > > By chance, does anyone have an LC script for handling a linked list
> > > (navigating, inserting, deleting)?
> > >
> > > Pete
> > > Molly's Revenge <http://www.mollysrevenge.com>
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list