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.