Pick random element: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m syntax highlighting fixup automation |
Added Odin variant |
||
Line 1,101: | Line 1,101: | ||
- : int = 3 |
- : int = 3 |
||
</pre> |
</pre> |
||
=={{header|Odin}}== |
|||
<syntaxhighlight lang="odin">package main |
|||
import "core:fmt" |
|||
import "core:math/rand" |
|||
main :: proc() { |
|||
list := []string{"foo", "bar", "baz"} |
|||
rand_index := rand.int_max(len(list)) |
|||
fmt.println(list[rand_index]) |
|||
}</syntaxhighlight> |
|||
=={{header|Oforth}}== |
=={{header|Oforth}}== |