August 23, 2024
P25 - Generate a random permutation of the elements of a list.
Hint: Use the solution of problem P23.
Example:
> p25:randomPermute([1,2,3,4,5,6,7]).
[3,1,5,4,6,7,2]
erlang
%Generate a random permutation of the elements of a list.
-module(p25).
-export([randomPermute/1]).
randomPermute(Ls) ->
p23:randomSelect(length(Ls), Ls).