JulioHerrlein Posted May 5, 2020 Share Posted May 5, 2020 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 Quote Link to comment Share on other sites More sharing options...
LdBeth Posted May 6, 2020 Share Posted May 6, 2020 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) ... JulioHerrlein 1 Quote Link to comment Share on other sites More sharing options...
JulioHerrlein Posted May 6, 2020 Author Share Posted May 6, 2020 Thank you ! I will try it ! Best, Julio Quote Link to comment Share on other sites More sharing options...
Stephane Boussuge Posted May 7, 2020 Share Posted May 7, 2020 Why not using combination in place of combination2 ? SB. JulioHerrlein 1 Quote Link to comment Share on other sites More sharing options...
LdBeth Posted May 7, 2020 Share Posted May 7, 2020 I guess it is because combinations like (a3 b3 c3 b3) are acceptable but won't be available with combination JulioHerrlein 1 Quote Link to comment Share on other sites More sharing options...
JulioHerrlein Posted May 7, 2020 Author Share Posted May 7, 2020 Thanks, Stephane ! It works great with combination, instead of combination 2. Best ! Julio Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.