Jump to content

Combination without repeating elements


Recommended Posts

Dear Friends,

 

I´m interested in the 4-note combinations of the diatonic scale without repeating elements.

 

(combination2 4 '(c3 d3 e3 f3 g3 a3 b3))

The filter-repeat and the remove-duplicates are not giving the right result.

 

PARTIAL RESULT,,,

combination2, size: 4
((b3 b3 b3 b3) (a3 b3 b3 b3) (g3 b3 b3 b3) (f3 b3 b3 b3) (e3 b3 b3 b3) (d3 b3 b3 b3) (c3 b3 b3 b3) (b3 a3 b3 b3) (a3 a3 b3 b3) (g3 a3 b3 b3) (f3 a3 b3 b3) (e3 a3 b3 b3) (d3 a3 b3 b3) (c3 a3 b3 b3) (b3 g3 b3 b3) (a3 g3 b3 b3) (g3 g3 b3 b3) (f3 g3 b3 b3) (e3 g3 b3 b3) (d3 g3 b3 b3) (c3 g3 b3 b3) (b3 f3 b3 b3) (a3 f3 b3 b3) (g3 f3 b3 b3) (f3 f3 b3 b3) (e3 f3 b3 b3) (d3 f3 b3 b3) (c3 f3 b3 b3) (b3 e3 b3 b3) (a3 e3 b3 b3) (g3 e3 b3 b3) (f3 e3 b3 b3) (e3 e3 b3 b3) (d3 e3 b3 b3) (c3 e3 b3 b3) (b3 d3 b3 b3) (a3 d3 b3 b3) (g3 d3 b3 b3) (f3 d3 b3 b3) (e3 d3 b3 b3) (d3 d3 b3 b3) (c3 d3 b3 b3) (b3 c3 b3 b3) (a3 c3 b3 b3) (g3 c3 b3 b3) (f3 c3 b3 b3) (e3 c3 b3 b3) (d3 c3 b3 b3) (c3 c3 b3 b3) (b3 b3 a3 b3) (a3 b3 a3 b3) (g3 b3 a3 b3) (f3 b3 a3 b3) (e3 b3 a3 b3) (d3 b3 a3 b3) (c3 b3 a3 b3) (b3 a3 a3 b3) (a3 a3 a3 b3) (g3 a3 a3 b3) (f3 a3 a3 b3) (e3 a3 a3 b3) (d3 a3 a3 b3) (c3 a3 a3 b3) (b3 g3 a3 b3) (a3 g3 a3 b3) (g3 g3 a3 b3) (f3 g3 a3 b3) (e3 g3 a3 b3) (d3 g3 a3 b3) (c3 g3 a3 b3) (b3 f3 a3 b3) (a3 f3 a3 b3) 

 

I want to filter OUT the sets like 

((b3 b3 b3 b3)
 (a3 b3 b3 b3)
 (g3 b3 b3 b3)
 (f3 b3 b3 b3)
 (e3 b3 b3 b3)
 (d3 b3 b3 b3)

 

With one or more repeating notes.

 

Best,

Julio

Link to post
Share on other sites

There's a count-repeat function.

 

? (count-repeat '(a3 b3 b3 b3))
count-repeat
(1 3)

 

Thus

(let ((*do-verbose* nil))
  (remove-if 
   (lambda (x) (> (apply #'max (count-repeat x)) 1)) ;; or replace apply with (reduce #'max (count-repeat x)), essentially does the same 
   (combination2 4 '(c3 d3 e3 f3 g3 a3 b3))))

((a3 b3 a3 b3) (g3 b3 a3 b3) (f3 b3 a3 b3) (e3 b3 a3 b3) (d3 b3 a3 b3) (c3 b3 a3 b3) (b3 g3 a3 b3) (a3 g3 a3 b3) (f3 g3 a3 b3) (e3 g3 a3 b3) (d3 g3 a3 b3) (c3 g3 a3 b3) (b3 f3 a3 b3) (a3 f3 a3 b3) (g3 f3 a3 b3) (e3 f3 a3 b3) (d3 f3 a3 b3) (c3 f3 a3 b3) (b3 e3 a3 b3) (a3 e3 a3 b3) (g3 e3 a3 b3) (f3 e3 a3 b3) (d3 e3 a3 b3) (c3 e3 a3 b3) (b3 d3 a3 b3) (a3 d3 a3 b3) (g3 d3 a3 b3) (f3 d3 a3 b3) (e3 d3 a3 b3) (c3 d3 a3 b3) (b3 c3 a3 b3) ...

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy