-2

I want to write maple code without using the permute function maple such that I that can get each permutation at a time and as I do not want to store all the permutations in a list as it would require too much memory space when n is larger.

So I would like to say I have to permute [1,2,3] first I get 1,2,3 leave it , next get 2,1,3 leave it, 3,2,1 leave it and so I don't store them after using it.

The same way for combinations too without using the combinat to store entire in a list i want say choose from 1,2,3,4 say 3 elements at a time I choose 1,2,3 leave it. Next I choose say 1,2,4 leave it without storing after I have just used it.

halfer
  • 19,824
  • 17
  • 99
  • 186
sriram
  • 5
  • 6

1 Answers1

0

You can use either the combinat:-nextperm command or the Iterator:-Permute command (more recent versions of Maple) to iterate over permutations individually.

In other words, these allow you to construct (and inspect/manipulate) the iterations individually without the full set being stored at any one time which is prohibitively expensive in memory. In fact, this is the primary purpose of these commands, to avoid storing the full set at once.

Similarly there are commands such as combinat:-nextcomb, etc, for combinations.

acer
  • 6,671
  • 15
  • 15