I am using the below module for shuffling a list for. eg. [1,2,3,4,5,6,7,8,9], I invoke function shuffle_list() in the yaws page. When I call this function in erlang shell it gives different each time.

shuffle_list(List) ->
%% Determine the log n portion then randomize the list.
   randomize(round(math:log(length(List)) + 0.5), List).

randomize(1, List) ->
   randomize(List);
randomize(T, List) ->
   lists:foldl(fun(_E, Acc) ->
                  randomize(Acc)
               end, randomize(List), lists:seq(1, (T - 1))).

randomize(List) ->
   D = lists:map(fun(A) ->
                    {random:uniform(), A}
             end, List),
   {_, D1} = lists:unzip(lists:keysort(1, D)),
   D1.

These are the curl logs

[root@TESTSVR ebin]# curl http://localhost:4545/getrandom.yaws?maximum=10
9,1,10,2,7,5,6,4,8,3
[root@TESTSVR ebin]# curl http://localhost:4545/getrandom.yaws?maximum=10
9,1,10,2,7,5,6,4,8,3
[root@TESTSVR ebin]# curl http://localhost:4545/getrandom.yaws?maximum=10
9,1,10,2,7,5,6,4,8,3
[root@TESTSVR ebin]# curl http://localhost:4545/getrandom.yaws?maximum=10
9,1,10,2,7,5,6,4,8,3
[root@TESTSVR ebin]# curl http://localhost:4545/getrandom.yaws?maximum=10
9,1,10,2,7,5,6,4,8,3
[root@TESTSVR ebin]# curl http://localhost:4545/getrandom.yaws?maximum=10
9,1,10,2,7,5,6,4,8,3


Thanks,
Marutha

On Sat, Sep 25, 2010 at 6:24 PM, Claes Wikstrom <klacke@tail-f.com> wrote:
On 09/25/2010 01:55 PM, Marutha wrote:
> Hi,
>
> I have a yaws file which would give me a list of random number when called upon taking a number as an inputs.
>
> But when I try to call I get the same list of random numbers . I feel this could be a cache things. How do I over come this. Please help.
>


Each GET typically runs in its own (new process) How do you seed the generator.

/klacke

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list