|
Post by regina on Nov 20, 2021 13:52:58 GMT
Hi,
I want to randomly select 2 values from an array. To do this, I wrote the code below. However "sample 2" does not work as shown by the size function. The array target_select contains as many values as the array target_order.
task set_order set &&target_order range 1 10 set &&target_order shuffle set &&target_select &&target_order sample 2 set &number &&target_select size save &number
block set_order tasklist set_order 1 end
I also tried an alternative way of doing this, see below. However, I need random selection without replacement. Yet, the code below does random selection with replacement.
task set_order set &&target_select random 1 10 times 2
Thank you, Regina
|
|
silk
Experienced
Posts: 32
|
Post by silk on Dec 16, 2021 14:36:30 GMT
Hi, I hope it is not too late. The syntax for the sample instruction is wrong in the main documentation. I recommend to always check the quick syntax overview page if something does not work. Sometimes you will find the right instruction here. So the syntax for the sample instruction is: set &&first_array sample [n] from &&second_array where [n] is the number of values in the sample.
|
|