Hi all,
I’d like to change the stream of value a Prand creates only after a number of time it repeats the same value pattern.
E.g. let’s say a Prand creates the following values: 1,2,4,4,3 then these five values repeat four times, only after which the stream of values change let’s say to 2,3,3,4,1 that repeats four times, etc.
I tried to solve this by embedding the Prand((1..4),5)
into Pn, Plazy, Pfunc, Pdup. I also tried with writing {(1..4).choose}!5
and then I got stuck as to how to use it as a stream. Pshuf didn’t seem to give the desired result. I was also trying to do something along the lines of Prand.collect but couldn’t wrap my head around how I can collect the values Prand creates 5 times and then use it as a stream of values. In all of these cases there was a missing element in the chain to achieve the above result. I checked forum discussions here but I couldn’t find any relevant thread.
Is there a short and simple way to do this? Or is Prand not even the way to go to achieve this?
Thanks,
cd