Jump to content

Featured Replies

Posted

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


Copyright © 2014-2025 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy