Is there a simple way to to make a consumableList of a subset of the larger list?
I’d like something like the following
originalList
A
B
C
D
[a = originalList.selectmany(2).consumableList]
in my dream, [a] should be a consumable list of two random elements from originalList.
Thanks!
3 Comments
Koto@lemmy.world · 2 pts · 1y
Yes, it's possible. The correct syntax would be
[a = originalList.consumableList.selectMany(2)]. Then, we'll need to make a list of that slice by using createPerchanceTree() with the correct escape characters. The function works like this:[newList = createPerchanceTree("slicedList\n\ta\n\tb").slicedList] [newList]danMiller@lemmy.world · 1 pts · 1y
If I understand this correctly, I think I lose having a consumable list as the final output. But it got me on the right track I think. THANKYOU!
I’m working with this now, which seems to produce a functional consumable list derived from a slice of the original list.
thanks again, I hadn’t stumbled across the createPerchanceTree command in the tutorials.
Koto@lemmy.world · 1 pts · 1y
You won't be losing consumable list on that created list, as you can .consumableList it again. Judging by your code, you figured it out!