[erlang-questions] beginner question

Ron Peterson rpeterso@REDACTED
Sun Aug 17 05:07:12 CEST 2008

When I compile the code below and run it, I get something like the

54> scrap:random_tuples( 20, 5 ).

I'm sure this is expected behaviour.  I'm just not yet familiar enough
with erlang to understand it.  Why isn't this the same as calling
random_tuple a number of times in succession?


set_seed_to_now() ->
    {A1, A2, A3} = now(),
    random:seed( A1, A2, A3 ).

for( Max, Max, F ) ->
for( I, Max, F ) ->
    [F|for( I+1, Max, F )].

random_tuple( Max ) ->
    { random:uniform( Max ), random:uniform( Max ) }.

random_tuples( Max, Num ) ->
    for( 1, Num, random_tuple( Max ) ).

Ron Peterson
Network & Systems Manager
Mount Holyoke College
I wish my computer would do what I want it to do - not what I tell it to do.

More information about the erlang-questions mailing list