Pick random element: Difference between revisions
Content deleted Content added
Factor solution |
→{{header|Pascal}}: add example |
||
Line 201: | Line 201: | ||
<lang php>$arr = array('foo', 'bar', 'baz'); |
<lang php>$arr = array('foo', 'bar', 'baz'); |
||
$x = $arr[array_rand($arr)];</lang> |
$x = $arr[array_rand($arr)];</lang> |
||
=={{header|Pascal}}== |
|||
<lang pascal>Program PickRandomElement (output); |
|||
const |
|||
s: array [1..5] of string = ('1234', 'ABCDE', 'Charlie', 'XB56ds', 'lala'); |
|||
begin |
|||
randomize; |
|||
writeln(s[low(s) + random(length(s))]); |
|||
end.</lang> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |