MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: a programming prob.



--- You wrote:
OBJECT.PROP = {"foo", {"bar", {"hello", "there"}, 
               "qwerty", {"quaz", {"poi", {"moo", "cows"}}}}};

and I had a verb that would return the numbers...
      {2, 4, 2, 2, 1}

so OBJECT.PROP[2][4][2][2][1] would be "moo".
How would I get another verb to find "moo" using those numbers without 
always having to have the same amount of numbers?
--- end of quoted material ---

cheap and offensive method:

temp = tostr(args[1],".",args[3]);
for x in (args[3])
   temp = tostr(temp,"[",x,"]");
endfor
return eval(temp);


better method:

:scanlist this none this
"args: {OBJECT.PROP, {2, 4, 2, 2, 1, . . .}}";

if (!args[2])
   return args[1];
endif
return this:scanlist(args[1][args[2]], listdelete(args[2]));


-manta (recursion-boy)



Home | Subject Index | Thread Index