I think I can eventually get my head around this problem, but I'm currently stuck and I'm wondering what suggestions other people have.
(Any mention of
compression and I will strap you to a rocket and fire it into the sun.)
Here's the problem:
I have a data stored like so:
"2,3,4,(1,2,3,4,(1,2),2),3,(4,5,6),((12,3,23),2,1),4"
So I want to convert that into an array. Each section in parenthesis implies a nested array.
What would that array be structured like? Well in as3 it would be like so:
myArray:Array = [2, 3, 4, [1, 2, 3, 4, [1, 2], 2], 3, [4, 5, 6], [[12, 3, 23], 2, 1], 4];
My first guess was to split the string at the commas and then try to start pushing and poping a stack whenever I hit any brackets.
(Actually my first guess was to use regex, but I know what you're going to reply to that.)
And my brain has kind of melted at the point where I'm trying to visualise how this pushing and popping business works in code. Any pointers?