Reputation: 21
I am trying to use a random number generator to fill two lists and then I will be deleting list 2 from list 1. The problem that I am getting is that it is not actually deleting anything from the list. I am new to Erlang so any help would be appreciated.
generate_number() ->
R1 = [[rand:uniform(10) || _ <- lists:seq(1, 10)]],
R2 = [[rand:uniform(10) || _ <- lists:seq(1, 10)]],
R3 = R1 -- R2,
io:format("Final List: ~p~n", R3).
Upvotes: 0
Views: 137
Reputation: 8390
You are using list comprehension in another list, which results in i.e. R1 = [[5,2,1,9,6,6,3,8,10,1]]
. Remove the outer square brackets and you should be fine:
%% ...
R1 = [rand:uniform(10) || _ <- lists:seq(1, 10)],
%% ...
Upvotes: 1