Hi Abinoam,

Thanks for reply, actually the first number is 'id' and second
'parent_id', so correct is:
["1=3D>0",
  ["2=3D>1",
    ["3=3D>2",
      ["7=3D>3"]
    ],"5=3D>1","6=3D>1"
  ],"4=3D>0"
]

From source flat:
[ "1=3D>0","2=3D>1", "3=3D>2","4=3D>0","5=3D>1","6=3D>1","7=3D>3"]

The purpose is to use such as menu like this, based in example above:
<menu>
  <ul>
    <li class=3D"sub">"1=3D>0"
      <ul>
        <li class=3D"sub">"2=3D>1"
          <ul>
            <li class=3D"sub">"3=3D>2"</li>
              <ul>
                <li>"7=3D>3"</li>
              </ul>
            </li>
          </ul>
        </li>
        <li>"5=3D>1"</li>
        <li>"6=3D>1"</li>
      </ul>
    </li>
    <li>"4=3D>0"</li>
  </ul>
</menu>

Thanks in advance!

On Fri, Jan 14, 2011 at 21:29, Abinoam Jr. <abinoam / gmail.com> wrote:
> Hi Marcello,
>
> For helping me understand your desired outcome I manually turned it
> into something more readable (just to read the nesting [] ).
>
> ["1=3D>0",["2=3D>1",["3=3D>2",["7=3D>3"]],["3=3D>2"]],["2=3D>1","5=3D>1",=
"6=3D>1"]]
>
> arr[0] =3D "1=3D>0"
> arr[1] =3D ["2=3D>1", ["3=3D>2", ["7=3D>3"]], ["3=3D>2"]]
> arr[2] =3D ["2=3D>1", "5=3D>1", "6=3D>1"]
>
> Is this what you want?
>
> On Fri, Jan 14, 2011 at 11:54 AM, Marcello Henrique <faraohh / gmail.com> w=
rote:
>> Hello,
>>
>> Short question:
>>
>> How to make an iterative method of stack?
>>
>> Long explanation:
>> I'm trying to create an iterative method for following structure:
>>
>> class Obj
>> =A0 attr_accessor: id,: parent_id
>>
>> =A0 def initialize (id, parent_id)
>> =A0 =A0 parent_id =3D @ parent_id
>> =A0 =A0 @ id =3D id
>> =A0 end
>>
>> =A0 def to_s
>> =A0 =A0 "id: # {@ id}, parent_id: @ # {parent_id} '
>> =A0 end
>> end
>>
>> left =3D [Obj.new (1.0), Obj.new (2.1), Obj.new (3.2), Obj.new (4.0),
>> Obj.new (5.1), Obj new (6.1), Obj.new (7.3)]
>>
>> My challenge is to make an iterative method, see how far I got:
>>
>> def menu_iterative (menu)
>> =A0 res =3D []
>>
>> =A0 el1 =3D menu.shift
>> =A0 res << el1
>> =A0 while not menu.empty?
>> =A0 =A0 res_aux =3D []
>> =A0 =A0 for i in menu
>> =A0 =A0 =A0 if el1.id =3D=3D i.parent_id
>> =A0 =A0 =A0 =A0 print el1, "=3D=3D" i "* ", res_aux.index (el1), "\ n"
>> =A0 =A0 =A0 =A0 res_aux << i
>> =A0 =A0 =A0 =A0 el1 =3D menu.delete (i)
>> =A0 =A0 =A0 =A0 retry
>> =A0 =A0 =A0 else
>> =A0 =A0 =A0 =A0 print el1, "! =3D" i, "\ n"
>> =A0 =A0 =A0 end
>> =A0 =A0 end
>> =A0 =A0 res << res_aux unless res_aux.empty?
>> =A0 =A0 puts
>> =A0 =A0 el1 =3D menu.shift
>> =A0 =A0 res << el1
>> =A0 end
>> =A0 return res
>> end
>>
>> puts "result:"
>> pp menu_iterative (left_it)
>>
>> I wish the outcome was:
>>
>> [*,
>> =A0[#<Obj:0x7f35b48cab18 @id=3D2, @parent_id=3D1>,
>> =A0[#<Obj:0x7f35b48caaf0 @id=3D3, @parent_id=3D2>,
>> =A0 [#<Obj:0x7f35b48caa50 @id=3D7, @parent_id=3D3>]],
>> =A0[#<Obj:0x7f35b48caaf0 @id=3D3, @parent_id=3D2>]],
>> =A0[#<Obj:0x7f35b48cab18 @id=3D2, @parent_id=3D1>,
>> =A0#<Obj:0x7f35b48caaa0 @id=3D5, @parent_id=3D1>,
>> =A0#<Obj:0x7f35b48caa78 @id=3D6, @parent_id=3D1>]]
>>
>> It seems that the problem is attribution without stack, correct?
>> I'm attaching all I did.
>>
>> Thanks for any help.
>> --
>> Marcello Henrique
>> Blog - http://faraohh.wordpress.com
>> Associa=E7=E3o Software Livre de Goi=E1s (www.aslgo.org.br)
>> Cercomp - UFG (www.cercomp.ufg.br)
>>
>
>



--=20
Marcello Henrique
Blog - http://faraohh.wordpress.com
Associa=E7=E3o Software Livre de Goi=E1s (www.aslgo.org.br)
Cercomp - UFG (www.cercomp.ufg.br)