Forum Discussion
dkent1982
Dec 02, 2022Copper Contributor
combine long list to fill a page at a time
I was given a long list provided with information containing three columns in order. I need to combine this list to where it stays in order but fill a page at a time. Below is a picture of what i hav...
Patrick2788
Dec 06, 2022Silver Contributor
I did some timings (5 timings went into each average).
The original array with 1,000 rows (3,000 elements), stacking 100 at a time - .000888 seconds.
An array of 100,000 rows (300,000 elements), stacking 1,000 - .00083 seconds
That's impressive. The recursive Lambda reads well because it's simple.
The original array with 1,000 rows (3,000 elements), stacking 100 at a time - .000888 seconds.
An array of 100,000 rows (300,000 elements), stacking 1,000 - .00083 seconds
That's impressive. The recursive Lambda reads well because it's simple.
mtarler
Dec 06, 2022Silver Contributor
Patrick2788 So I was looking at ways the function might be improved and noted that I could replace CHOOSEROWS(array of rows) with TAKE(DROP(x)y) and was wondering if that would be better or worse (original followed by variation):
ReshapeXrows = LAMBDA(in, rows,
LET(
i, EXPAND(in, ROUNDUP(ROWS(in) / rows, 0) * rows, , ""),
DROP(
REDUCE(
"",
SEQUENCE(ROWS(i)/rows, , 0, rows),
LAMBDA(u, v, HSTACK(u, CHOOSEROWS(i, SEQUENCE(rows) + v)))
),
,
1
)
)
);
Reshape = LAMBDA(in, rows,
LET(
i, EXPAND(in, ROUNDUP(ROWS(in) / rows, 0) * rows, , ""),
DROP(
REDUCE(
"",
SEQUENCE(ROWS(i)/rows, , 0, rows),
LAMBDA(u, v, HSTACK(u, Take(drop(i, v-1),rows)))
),
,
1
)
)
);Based on a VERY informal test I believe the CHOOSEROWS is better than the TAKE(DROP())
- Patrick2788Dec 06, 2022Silver Contributor
CHOOSEROWS does seem a bit faster. TAKE/DROP is a good swap for INDEX in some situations.
Data sample: 20,000 x 1 array
5 timings: .000382 seconds avg
=TAKE(DROP(E1#,10000),10000)5 timings: .000376 seconds avg
=CHOOSEROWS(E1#,SEQUENCE(10000,,10001))