Logo

Programming-Idioms

History of Idiom 11 > diff from v12 to v13

Edit summary for version 13 by :

Version 12

2015-08-27, 19:09:11

Version 13

2015-08-27, 21:57:32

Idiom #11 Pick a random element from a list

List x must be non-empty.

Idiom #11 Pick a random element from a list

List x must be non-empty.

Imports
classes
Imports
classes
Code
element := x.Items[random(x.count)];
Code
element := x.Items[random(x.count)];
Comments bubble
If x is a TList or TStrings -descendent
Comments bubble
If x is a TList or TStrings -descendent
Origin
http://www.programming-idioms.org/idiom/11/pick-a-random-element-from-a-list/618/delphi