Pick random element: Difference between revisions

Content deleted Content added
Steenslag (talk | contribs)
→‎{{header|Ruby}}: Removed "choice", Ruby 1.8 support ended in 2013 https://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/
BigL (talk | contribs)
No edit summary
Line 695:
 
Random picks from list: Seven Nine Two Six Four Four Nine Three Six Two</pre>
===Easy version===
<lang purebasic>Define.i
OpenConsole()
 
a$="One" +#TAB$+ "Two" +#TAB$+ "Three" +#TAB$+ "Four" +#TAB$+ "Five" +#TAB$+
"Six" +#TAB$+ "Seven"+#TAB$+ "Eight" +#TAB$+ "Nine" +#TAB$+ "Ten" +#TAB$
 
Print("Source list: "+#TAB$+a$+#CRLF$+"Random list: "+#TAB$)
 
For i=1 To CountString(a$,#TAB$)
Print(StringField(a$,Random(CountString(a$,#TAB$),1),#TAB$)+#TAB$)
Next
Input()</lang>
{{out}}
<pre>
Source list: One Two Three Four Five Six Seven Eight Nine Ten
Random list: One Two Seven Nine Ten Seven Three Five Ten Nine
</pre>
=={{header|Python}}==
<lang python>>>> import random