Re: Too complex!!!!!!!!!
hi Lucius,
I found a solution to your deflatten problem. It work on every sample I
tested.
function DeFlatten(sequence s)
integer i, l
sequence d, stack
if length(s) < 2 then
return {}
end if
d = {}
stack = {}
i = 1
l = 0
while i <= length(s) do
if s[i] > 0 then
if l > 0 then
stack = append(stack,{l,d})
end if
l = s[i]
d = {}
i = i + 1
elsif s[i] = 0 then
if l > 0 then
d = append(d,{})
end if
i = i + 1
else
d = d & s[i+1]
i = i + 2
end if
while length(d) = l and length(stack) do
d = append(stack[length(stack)][2],d)
l = stack[length(stack)][1]
stack = stack[1..length(stack)-1]
end while
end while
if length(stack) then
for j = length(stack) to 1 by -1 do
d = append(stack[j][2],d)
end for
end if
return d
end function -- DeFlatten()
Jacques Deschenes
Baie-Comeau, Quebec
Canada
desja at quebectel.com
|
Not Categorized, Please Help
|
|