It would be nice to have an equivalent of llList2List as part of the table API
under review
Fizz Savira
Something like table.slice(src: {...}, from: number, to: number) -> {...}
Or maybe table.slice(src: {...}, start: number, amount: number?) -> {...} where amount is optional and works like string.sub(...)
Log In
Tapple Gao
As I'm the one who submitted the PR to deprecate ll.List2List, I feel a bit responsible and have kept this feedback on my mind. I've been dogfooding in my own code whether I can replace
ll.List2List
in every instance. So far I can. Unlike all of the other list function deprecations in that PR, this one actually does have a direct substitution (two in fact: unpack
and table.move
). Here's what I've actually replaced it with, from most to least common:- changing strided lists to lists of dictionaries
- string.gsub(when used withstring.splitandtable.concat)
Some other replacements that have been proposed, but I haven't yet used in my code:
- using the optional 3rd and 4th parameters of table.concat
- using the optional 2nd and 3rd parameters of unpack/table.unpack(a direct substitution)
- 'table.move(..., 1, {})` (a direct substitution)
Tapple Gao
Notably, I have not yet used either of
ll.List2List
's nearly-direct substitutions. These are equivalent when a and b are positive. The direct substitutions are:ll.List2List(list, a, b)
table.move(list, a, b, 1, {})
{unpack(list, a, b)}
I suspect having these direct substitutions helped make the case to deprecate
ll.List2List
M
Mercury Linden
updated the status to
under review
Tapple Gao
alternately, we could revert the deprecation of ll.List2List
Tapple Gao
ll.List2List(list, a, b)
is exactly equivilant to
{unpack(list, a, b)}
except I usually don't even need the surrounding '{}', because I'd rather have the values inside the list as local variables
SuzannaLinn Resident
I vote for
table.slice(src: {...}, from: number, to: number?) -> {...}
, with to
defaulting to #src
SungAli Resident
SuzannaLinn Resident I agree, and for completeness, have from default to 1.