Pick random element: Difference between revisions
Content deleted Content added
→{{header|AutoHotkey}}: Updated |
→{{header|Matlab/Octave}}: pick random element |
||
Line 189: | Line 189: | ||
<lang Mathematica>RandomChoice[{a, b, c}] |
<lang Mathematica>RandomChoice[{a, b, c}] |
||
->c</lang> |
->c</lang> |
||
=={{header|MATLAB}} / {{header|Octave}}== |
|||
In case list is a cell array: |
|||
<lang Matlab> list = {'a','b','c'}; |
|||
list{ceil(rand(1)*length(list))}</lang> |
|||
If list is a vector: |
|||
<lang Matlab> list = 1:1000; |
|||
list(ceil(rand(1)*length(list)))</lang> |
|||
=={{header|OCaml}}== |
=={{header|OCaml}}== |