Get Random Element(s) from a List

后端 未结 0 1778
忘了有多久
忘了有多久 2021-02-11 17:01

I\'m basically looking for an Elixir equivalent of Ruby\'s Array#sample. Something that would let me do this:

list = [1,2,3,4,5,6,7]

sample(list)
#=> 4

samp         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题