Shop OBEX P1 Docs P2 Docs Learn Events
Multi-Dimensional Arrays in SPIN? — Parallax Forums

Multi-Dimensional Arrays in SPIN?

Bruce BatesBruce Bates Posts: 3,045
edited 2006-04-07 15:22 in Propeller 1
SPIN Gurus -

We've already established that SPIN supports arrays, but does it support multi-dimensional arrays? That would certainly give it quite a bit of added "punch" if it does, even at a minimalist level. What I mean by that is no dynamic arrays (although that would be SUPER!), and (say) limited to two or three dimensions.

TIA

Regards,

Bruce Bates


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-06 21:53
    Bruce,

    There are two ways to do multidimensional arrays in Spin:

    1. Simulate it via a single dimension: x[noparse][[/noparse]j][noparse][[/noparse]k] == x[noparse][[/noparse]j * n + k], where n is the size of the "k" dimension.

    2. Use pointers: word[noparse]/noparse]x[noparse][[/noparse]j[noparse][[/noparse]k], where x[noparse][[/noparse]j] points to another array, which is indexed by k.

    BTW, I've written a heap manager for dynamic allocation. It's written in Spin and is still in beta testing.

    -Phil
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-04-07 15:22
    Nice, sweet... super sweet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
Sign In or Register to comment.