<div><div dir="auto">How about this: (note: use whatever seeding you need)</div></div><div dir="auto"><br></div><div dir="auto">rand:seed(exsplus, {1,2,3}),</div><div dir="auto">AThousand = lists:seq(1, 1000),</div><div dir="auto">[[rand:uniform() || _ <- AThousand]</div><div dir="auto"> || _ <- AThousand</div><div dir="auto">]</div><div><br><div class="gmail_quote"><div dir="ltr">On Tue 3 Jul 2018 at 08:33, Raimo Niskanen <<a href="mailto:raimo%2Berlang-questions@erix.ericsson.se">raimo+erlang-questions@erix.ericsson.se</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Jul 03, 2018 at 01:15:17PM +0900, <a href="mailto:zxq9@zxq9.com" target="_blank">zxq9@zxq9.com</a> wrote:<br>
> On 2018年7月2日月曜日 23時36分10秒 JST Awsaf Rahman wrote:<br>
> > Hello!<br>
> > <br>
> > I am trying to determine the execution time for my matrix multiplication<br>
> > program and for that I need to generate a large enough List of Lists of<br>
> > random integers. Say I want to generate a matrix with a 1000 rows (that is<br>
> > 1000 lists inside a list). Is there any way of doing it? I can generate a<br>
> > list of random numbers using list comprehension but can't figure out how to<br>
> > go about building a list of lists.<br>
> <br>
> Wheels within wheels, man...<br>
> <br>
> -module(genset).<br>
> -export([generate/1]).<br>
> <br>
> generate(Size) -><br>
> Generate = fun() -> rand:uniform(1000) end,<br>
> MakeList = fun() -> populate(Generate, Size, []) end,<br>
> populate(MakeList, Size, []).<br>
> <br>
> <br>
> populate(_, Size, Acc) when Size < 0 -><br>
> Acc;<br>
> populate(Generate, Size, Acc) -><br>
> populate(Generate, Size - 1, [Generate() | Acc]).<br>
> <br>
> <br>
> -Craig<br>
<br>
This may be a missing function for the lists module:<br>
<br>
buildr(N, Fun, Acc) -><br>
buildr(N, Fun, Acc, []).<br>
%%<br>
buildr(0, _Fun, Acc, R) -><br>
{R, Acc};<br>
buildr(N, Fun, Acc, R) -><br>
{V, NewAcc} = Fun(Acc),<br>
buildr(N - 1, Fun, NewAcc, [V|R]).<br>
<br>
Example usage:<br>
<br>
Base = 0,<br>
Range = 1 bsl 32,<br>
{ListOfLists, _NewSeed} =<br>
buildr(<br>
1000,<br>
fun (Seed) -><br>
buildr(<br>
1000,<br>
%%fun rand:uniform_s/1,<br>
fun (S) -><br>
{V, NewS} = rand:uniform_s(Range, S),<br>
{Base + V - 1, NewS}<br>
end,<br>
Seed)<br>
end,<br>
rand:seed_s(exrop)),<br>
<br>
-- <br>
<br>
/ Raimo Niskanen, Erlang/OTP, Ericsson AB<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div><br></div><div>Cheers,</div><div>-- </div><div>Pierre Fenoll</div></div><div><br></div></div></div>