How to create a list of 1000 random numbers in Erlang?

后端 未结 6 1900
深忆病人
深忆病人 2020-12-17 15:38

I\'m sure that there is a function for that. I just want to make a list of 1000 numbers, each one of them which should be random.

6条回答
  •  伪装坚强ぢ
    2020-12-17 16:33

    From Erlang Central wiki:

    http://erlangcentral.org/wiki/index.php?title=Random_Numbers

    Where N = no of items, StartVal = minimum value and Lim = maximum value

    generate_random_int_list(N,StartVal,Lim) ->
        lists:map(fun (_) -> random:uniform(Lim-StartVal) + StartVal end, lists:seq(1,N)).
    

提交回复
热议问题