Attempting to create a new list from a list of values and frequencies

Alternate method! I chatted with Jay off-forum, and he found a way that avoids my messy cumulative frequency index stuff. Here’s the thinking:

Challenge: [L[i] for i=[1...F[i]], i=[1...length(L)]] doesn’t work to repeat data value L[i] exactly F[i] times, because i is seen as a free variable for the comprehension.
Solution: Repeat each data value a fixed number of times, then filter down to get the correct number of values!

2 Likes