This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
4rpl:commands:getlistelement [2021/01/24 18:35] – karsten75 | 4rpl:commands:getlistelement [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~NOTOC~~ | + | \\ |
+ | < | ||
< | < | ||
<WRAP tabs> | <WRAP tabs> | ||
Line 20: | Line 21: | ||
Trace (< | Trace (< | ||
loop | loop | ||
+ | </ | ||
+ | |||
+ | <code 4rpl> | ||
+ | # A 2-line code that gets a random element from a provided list. | ||
+ | RandInt(0 GetListCount(< | ||
+ | GetListElement(< | ||
+ | </ | ||
+ | |||
+ | <code 4rpl> | ||
+ | # A function for selecting a random element from a list: | ||
+ | 1 2 4 8 16 list ->list | ||
+ | |||
+ | <-list @selectRandomElement -> | ||
+ | |||
+ | : | ||
+ | Dup | ||
+ | Getlistcount 0 swap RandInt | ||
+ | Getlistelement | ||
</ | </ | ||
< | < | ||