参考karl's answer

1> L = lists:seq(1,10).
[1,2,3,4,5,6,7,8,9,10]

Associate a random number R with each element X in L by making a list of tuples {R, X}. Sort this list and unpack the tuples to get a shuffled version of L.

2>[X||{_, X} <- lists:sort([{random:uniform(), N} || N <- L])].
[5,2,3,1,7,4,6,9,10,8]
3>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-03
  • 2022-03-01
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
相关资源
相似解决方案