Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Nested array filling well.. but tricky search back

Reply
Thread Tools

Nested array filling well.. but tricky search back

 
 
Josselin
Guest
Posts: n/a
 
      09-24-2007
thanks to your help..

I got a nice nested array

ALL_CATEGORIES = [[[1, "category1"], [2, "category2"], [3,
"category3"], [4, "category4"]], [[5, "category5"], [6, "category6"],
[7, "category7"], [8, "category8"]], [[9, "category9"], [10,
"category10"], [11, "category11"], [12, "category12"], [13,
"category13"], [14, "category14"], [15, "category15"]], [[16,
"category16"], [17, "category17"], [18, "category18"], [19,
"category19"]], [[20, "category20"], [21, "category21"], [22,
"category22"]], [[23, "category23"], [24, "category24"], [25,
"category25"], [26, "category26"], [27, "category27"], [28,
"category28"]], [[29, "category29"], [30, "category30"], [31,
"category31"]

so I can get :
all categories of first domain
ALL_CATEGORIES[0] => [[1, "category1"], [2, "category2"], [3,
"category3"], [4, "category4"]]
first category of first domain
ALL_CATEGORIES[0][0] => [1, "category1"]
category index of first category of first domain
ALL_CATEGORIES[0][0][0] => 1
category label of first category of first domain
ALL_CATEGORIES[0][0][1] => "category1"

is there any easy way to find back the domain index from the category
index ? or should I rewrite my array ?

given category index 5 then domain index would be 1
I would find it in ALL_CATEGORIES[1] => [[5, "category5"], [6,
"category6"], [7, "category7"], [8, "category8"]]

thanks fyh

joss

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I don't quite understand tricky reg ex with back ref Jedrin Ruby 1 02-18-2012 03:55 AM
tricky nested list unpacking problem Reckoner Python 7 12-16-2008 05:18 PM
Nested array filling bad.. Josselin Ruby 4 09-24-2007 10:19 AM
Search on combination of two columns - tricky one JP SIngh ASP General 1 08-15-2006 03:11 PM
a tricky if else(maybe not tricky but impossible) nirkheys@gmail.com C Programming 9 04-25-2006 06:13 PM



Advertisments