Skip to content
View in the app

A better way to browse. Learn more.

Learn more

Permute Function Question

Featured Replies

I need a function to filter the Permutations.

 

For example:

 

(gen-divide 2 (flatten (permute (pcs '4-1))))

 

Will result in:

 

((0 1) (2 3) (0 1) (3 2) (0 2) (1 3) (0 2) (3 1) (0 3) (1 2) (0 3) (2 1) (1 0)
 (2 3) (1 0) (3 2) (1 2) (0 3) (1 2) (3 0) (1 3) (0 2) (1 3) (2 0) (2 0) (1 3)
 (2 0) (3 1) (2 1) (0 3) (2 1) (3 0) (2 3) (0 1) (2 3) (1 0) (3 0) (1 2) (3 0)
 (2 1) (3 1) (0 2) (3 1) (2 0) (3 2) (0 1) (3 2) (1 0))

 

But I don't mind with the order, since I'll make chords out of it, so

 

((0 1) (2 3) or (0 1) (3 2) or (1 0) (2 3)  will result in the same chord.

 

How to filter the list onto a list where the order does not matter ?

 

Best,

 

Julio

 

  • Author

Possible workaround:

 

(remove-duplicates (sort-asc (combination 3 (pcs '6-1))) :test #'equal)

 

Create an account or sign in to comment

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.