Skip to content
View in the app

A better way to browse. Learn more.

Learn more

replace-map Question

Featured Replies

Dear All,

 

I´m doing some melodic permutations and I have a question about replace-map:

Here are four elements permutations, generated by:

(permute '(1 2 3 4))
(setf permut4 '((1 2 3 4) (1 2 4 3) (1 3 2 4) (1 3 4 2) (1 4 2 3)
                (1 4 3 2) (2 1 3 4) (2 1 4 3) (2 3 1 4) (2 3 4 1)
                (2 4 1 3) (2 4 3 1) (3 1 2 4) (3 1 4 2) (3 2 1 4)
                (3 2 4 1) (3 4 1 2) (3 4 2 1) (4 1 2 3) (4 1 3 2)
                (4 2 1 3) (4 2 3 1) (4 3 1 2) (4 3 2 1)))

Here are the pitch material to be permutated:

(setf permutcontent '((1 cs4) (2 d4) (3 e4) (4 g4)))

I used the REPLACE MAP FUNCTION, like this:

(replace-map permutcontent permut4)

 

THE RESULT:

((c4 d4 e4 g4) (c4 d4 g4 e4) (c4 e4 d4 g4) (c4 e4 g4 d4) (c4 g4 d4 e4)
 (c4 g4 e4 d4) (d4 c4 e4 g4) (d4 c4 g4 e4) (d4 e4 c4 g4) (d4 e4 g4 c4)
 (d4 g4 c4 e4) (d4 g4 e4 c4) (e4 c4 d4 g4) (e4 c4 g4 d4) (e4 d4 c4 g4)
 (e4 d4 g4 c4) (e4 g4 c4 d4) (e4 g4 d4 c4) (g4 c4 d4 e4) (g4 c4 e4 d4)
 (g4 d4 c4 e4) (g4 d4 e4 c4) (g4 e4 c4 d4) (g4 e4 d4 c4))

 

THE QUESTION:

What if I want to replace one item (like a pitch) for a list of melodic pitches ?

How to proceed ?

 

For example:

Instead of substitute a C4 for the number 1, I want to substitute a list of notes, like (cs4 ds4)

(setf permutcontent '((1 cs4 ds4) (2 d4) (3 e4) (4 g4)))

 

When I set this, a get only the cs4 permeated...

 

Best,

Julio

 

I got it !

 

All the material must have the same number of elements, like

(setf permutcontent '((1 (c4 cs4)) (2 (b4 ds4)) (3 (c5 f4)) (4 (cs5 ds4))))

 

Resulting in:

((c4 cs4) (b4 ds4) (c5 f4) (cs5 ds4))
((c4 cs4) (b4 ds4) (cs5 ds4) (c5 f4))
((c4 cs4) (c5 f4) (b4 ds4) (cs5 ds4))
((c4 cs4) (c5 f4) (cs5 ds4) (b4 ds4))
((c4 cs4) (cs5 ds4) (b4 ds4) (c5 f4))
((c4 cs4) (cs5 ds4) (c5 f4) (b4 ds4))
((b4 ds4) (c4 cs4) (c5 f4) (cs5 ds4))
((b4 ds4) (c4 cs4) (cs5 ds4) (c5 f4))
((b4 ds4) (c5 f4) (c4 cs4) (cs5 ds4))
((b4 ds4) (c5 f4) (cs5 ds4) (c4 cs4))
((b4 ds4) (cs5 ds4) (c4 cs4) (c5 f4))
((b4 ds4) (cs5 ds4) (c5 f4) (c4 cs4))
((c5 f4) (c4 cs4) (b4 ds4) (cs5 ds4))
((c5 f4) (c4 cs4) (cs5 ds4) (b4 ds4))
((c5 f4) (b4 ds4) (c4 cs4) (cs5 ds4))
((c5 f4) (b4 ds4) (cs5 ds4) (c4 cs4))
((c5 f4) (cs5 ds4) (c4 cs4) (b4 ds4))
((c5 f4) (cs5 ds4) (b4 ds4) (c4 cs4))
((cs5 ds4) (c4 cs4) (b4 ds4) (c5 f4))
((cs5 ds4) (c4 cs4) (c5 f4) (b4 ds4))
((cs5 ds4) (b4 ds4) (c4 cs4) (c5 f4))
((cs5 ds4) (b4 ds4) (c5 f4) (c4 cs4))
((cs5 ds4) (c5 f4) (c4 cs4) (b4 ds4))
((cs5 ds4) (c5 f4) (b4 ds4) (c4 cs4)))

 

But would be nice to MIX different number of elements...

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.