Re: splitting to sublist - HELLPPPP
- Posted by petelomax May 30, 2018
- 1260 views
You're not really giving us very much to go on there, are you sunshine?
Just for a laugh, and with a massive load of guesswork, the best I can manage:
function restructure(sequence s, sequence sublens) sequence res = {} integer idx = 1 for i=1 to length(sublens) do integer sublen = sublens[i] if sublen then sequence sub = s[idx..idx+sublen-1] sub[1][1] = 1000 for j=2 to sublen do sub[j][1] = 1002 end for res = append(res,sub) end if idx += max(sublen,1) end for return res end function ?restructure({{1000,90},{1002,80},{1002,90},{1002,90},{1002,90},{1002,80},{1002,90},{1002,90},{1002,80}},{2,1,0,2,1,2}) ?restructure({{1000,90},{1000,80},{1000,90},{1000,90},{1000,90},{1000,80},{1000,90},{1000,90},{1000,80}},{4,2,1,2})
output:
{{{1000,90},{1002,80}},{{1000,90}},{{1000,90},{1002,80}},{{1000,90}},{{1000,90},{1002,80}}} {{{1000,90},{1002,80},{1002,90},{1002,90}},{{1000,90},{1002,80}},{{1000,90}},{{1000,90},{1002,80}}}