how to interleave a single symbol in a list?

manmusic's icon

how to interleave a single symbol (,) in a list?

1 2 3 4 5 .../... to 1, 2, 3, 4, 5 .../...

ch's icon

my max is a bit rusty, so there might be a more efficient/shorter solution, but you can use iter/zl group, like that :

Max Patch
Copy patch and select New From Clipboard in Max.

manmusic's icon


exactly that! thank you very much

Roman Thilenius's icon


there is also an [iter] object, but [zl iter 1] looks somehow more sexy.

manmusic's icon

I have a problem with zl lace. I want to get a list (x y, x y,) for a function. lace removes some commas. Why?

How to make it more direct?

Zl lace error.json
application/json 6.99 KB

Vincent Goudard's icon

Hi manmusic,
I think this is somewhat of a misuse of lists in Max : a list, when written in a message box and clicked is iterating its elements, so you cannot really "lace" them the way you do. (More generally, it is not a good idea to format a message-box content if you plan to process this content as data.)
If you want to lace your two lists as 2-elements couples, you can do it this way:

Max Patch
Copy patch and select New From Clipboard in Max.

And btw, you can copy-compress your patch to post them, it's easier to copy them ;)
HTH
Vincent

manmusic's icon

Thank you Vincent. But that doesn't correspond situation. I need to interleave my two lists to send it to the object object. Arguments must be separated by a comma (1 1.0, 2 2.0, ... / ...). I can't place the comma in the right place in my final list!

Zl lace error 2.maxpat
Max Patch

Vincent Goudard's icon

Which object are you dealing with ?
Do you really need to pass it through a message-box ?
If you provide some more context for your patch, I might give you a better answer...
...
also, please copy-compressed you patch when you post it here ! :)

Vincent Goudard's icon

Is that what you're trying to do ?

Max Patch
Copy patch and select New From Clipboard in Max.

manmusic's icon

This is a big part of the project. The data from the function object then goes to an arduino.

Max Patch
Copy patch and select New From Clipboard in Max.

Vincent Goudard's icon

ok, but when do you eventually need to connect your message box to another object ?
It is not connected in your patch...

Max Patch
Copy patch and select New From Clipboard in Max.

Trying to plot the data from the dict ?

manmusic's icon


Thank you vincent! This is exactly what I was looking for

manmusic's icon

Excuse me Vincent but I realize that I am missing something. The function object should be on a domain of at least "168981" and not "24". Function is used to control servo motors. On a rail. I need a great fluidity of movement on a displacement of 1'49 ". I would need 7347 steps between each coordinate. I still can't find the solution.


the objective is to simulate the sea tide movements of a day between two shores in 1 minute 49 seconds.
the line object doesn't interest me. I want to be able to control the transport.

Max Patch
Copy patch and select New From Clipboard in Max.

Vincent Goudard's icon

"24" is just the size of the array storing the data in your patch (and is dynamically set by zl len, in the case this size changes).
You may indeed need to scale your data to match the range of your {performance duration, servo motor control range, whatever process}.
If you need a finer-grain control, you may also need to upsample your data, for which the simplest option I can think of would be simply to interpolate linearly between 2 adjacent values.
BTW, the "function" object is doing that for you (the "produce interpolated y for this x at left outlet" comment in the help patcher.)

manmusic's icon

It bothers me. The data in the "Dic" are sea levels over a period of 24 hours.
I'm trying to see if there are solutions with "RegExp".
I'm having trouble with PERL (I'm finding out. I'm not sure this is the right solution to interweave two lists and integrate a comma in the right place). Maybe I should try it in Javascript, but I don't know enough about the language. "sfpring" is limited in entry.
In short, I want to be able to vary my X / Y coordinates (Sea height on time upstream).
Intertwine them to give X/y and followed by a comma seems to me the most direct method. But I can not.

Source Audio's icon

this is as simple as it could be ...
zl lace should output list as is.
then zl iter 2 and append comma

Max Patch
Copy patch and select New From Clipboard in Max.