<Extension>
Public Iterator Function Repeat(Of T)(element As T) As IEnumerable(Of T)
While True
Yield element
End While
End Function
<Extension>
Public Iterator Function Repeat(Of T)(source As IEnumerable(Of T)) As IEnumerable(Of T)
While True
For Each item In source
Yield item
Next
End While
End Function
<Extension>
Public Iterator Function RandomUsing(Of T)(source As IEnumerable(Of T), random As Random) As IEnumerable<T>
Dim list = source.ToList()
While True
Dim index = random.Next(list.Count)
Yield list(index)
End While
End Function
<Extension>
Public Function RandomOrderUsing(Of T)(source As IEnumerable(Of T), random As Random) As IEnumerable(Of T)
Return source.OrderBy(Function(a) random.Next())
End Function
Created
January 29, 2016 16:05
-
-
Save peace2048/ccb5735e4e99d307912a to your computer and use it in GitHub Desktop.
Random
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment