Random function 2
- Posted by aku at inbox.as Mar 11, 2001
- 470 views
How I get x items randomly from a sequence that has length y, where y > x, but no duplicate items in x? This function (untested): function getsome(object howmany, object y) object result, r result = {} for i=1 to howmany do r = rand(length(y)) result = append(result, y[r]) y = y[1..r-1] & y[r+1..length(y)] end for return result end function seems to be inefficient. Any suggestion? Thanks!