Code War: Quick Structure Check
- Posted by "Lucius L. Hilley III" <lhilley at CDC.NET> May 09, 2000
- 624 views
I will be working with multidimensional data that will be required to adhere to strict structuring. A simple example would be a 3D array. sequence s s = repeat(repeat(repeat(0,2),3),4)-- this is equal to. s = { {{0,0},{0,0},{0,0}}, {{0,0},{0,0},{0,0}}, {{0,0},{0,0},{0,0}}, {{0,0},{0,0},{0,0}} } Testing specifically for this exact structure is very easy. HOWEVER, there is a slight twist to the assignment. s = { --this should fail. { 0 ,{0,0},{0,0}}, --error 0, --error {0, 0, 0, 0}, -error {{0,0},{0,0},{0,0}} } s = { --this should pass. {{} ,{0,0,0}}, {{0,0},{0,0},{0,0},{0,0,0}}, {{},{}} } Notice that if it is declared a sequence then it MUST be a sequence BUT it doesn't have to be of the exact length requested. Any clues on how to QUICKLY handle this versatility. I will be writing a slow recursive calling routine to handle this for now. I would much prefer some sort of magic using sequences and compares or something of that nature. Lucius L. Hilley III lhilley at cdc.net +--------------+--------------+ | ICQ: 9638898 | AIM: LLHIII | +--------------+--------------+ | http://www.cdc.net/~lhilley | +-----------------------------+