tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,40 @@
|
|||
Procedure.s pickRandomElement(List source.s())
|
||||
Protected x = ListSize(source())
|
||||
|
||||
If x > 0
|
||||
SelectElement(source(), Random(x - 1)) ;element numbering is zero - based
|
||||
ProcedureReturn source()
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
;initialize list elements
|
||||
DataSection
|
||||
elements:
|
||||
Data.s "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"
|
||||
EndDataSection
|
||||
|
||||
#elementCount = 10
|
||||
NewList item.s()
|
||||
|
||||
Restore elements
|
||||
Define i
|
||||
For i = 1 To #elementCount
|
||||
AddElement(item())
|
||||
Read.s item()
|
||||
Next
|
||||
|
||||
If OpenConsole()
|
||||
Print("Source list: ")
|
||||
ForEach item()
|
||||
Print(item() + " ")
|
||||
Next
|
||||
PrintN(#CRLF$)
|
||||
|
||||
Print("Random picks from list: ")
|
||||
For i = 1 To 10
|
||||
Print(pickRandomElement(item()) + " ")
|
||||
Next
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue