Appending elements to a list

I wanted to some like [[2, 3, 4, 5, 6], [1, 3, 4, 5, 6], [1, 2, 4, 5, 6], [1, 2, 3, 5, 6], [1, 2, 3, 4, 6], [1, 2, 3, 4, 5]]

I think the basic issue was due to variables being immutable. I got the solution using recursion instead of for. Some thing like this-

def my_function(i,n,list,n_list) do
  if i < n do
    n_list = my_function(i+1,n,list,n_list) ;
  end
  temp_list = List.delete_at(list,i-1) ;
  [ temp_list | n_list] ;
end

calling it using new_list = my_function(1,n,list,[]) ;

where list = [1,2,3,4,5,6]

Suggestions for corrections and improvements are welcomed :slight_smile: