0

I am attempting to implement a version of permutation using a function I already wrote i'm calling pair-divide which gives me all the possible pair combinations of a list. For example (list 9 10 11) would become the list of tuples

(list (tuple empty (9 10 11))
      (tuple (9)   (10 11))
      (tuple (9 10) (11))
      (tuple (9 10 11) empty)))

My idea to implement permutation is this:

Use pair-divide to create the tuples of a single element e.g

(pair-divide 1) = 
(list (tuple empty (1))
      (tuple (1) empty)))

Then insert the next element in the given list into the middle of these tuples. Then repeat until the list is empty.

In my mind, that should enable me to create all the possible variations of a given list, but I am struggling to understand how to actually implement this idea.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
jackr
  • 11
  • you can find some pseudocode [here](https://stackoverflow.com/a/65996009/849891), browse the [tag:permutation] tag or search [this](https://stackoverflow.com/questions/tagged/permutation+scheme) or [that](https://stackoverflow.com/questions/tagged/permutation+lisp). :) and here's [another answer](https://stackoverflow.com/a/66033083/849891) of mine, with links, which could be relevant. – Will Ness Feb 15 '21 at 07:54
  • you're welcome. so what came out of all this? were you able to find the solution? if so, it is perfectly fine and encouraged on SO to post your own answer, and later even accept it, to signal that the issue is closed. you might get some up-votes on the answer, too. :) – Will Ness Feb 22 '21 at 17:55

0 Answers0