MariaRose

Hi All,
very new in using OM I need a function which connects two lists like that
(1 2 3 4) (1.1 2.1 3.1 4.2) ——> (1 1.1 2 2.1 3 3.1 4 4.2) maybe someone may help
(till now found nothing like that in the documentary.. but maybe I didn’t saw its so much information there.. )
Thanks ..
Best,
Lena

perti

hello lena,
i’m really interested in how to do this in openmusic. i tried with omloop to no avail. for the moment you could define an internal lisp function like this:
(lambda (l1 l2) (loop for i in l1
for j in l2
collect i collect j))
please have in mind that this will interleave the two lists but up to the shortest one, leaving out the rest of the elements of the longest list.
hope this helps,
regards,
m.

This reply was modified 3 months, 4 weeks ago by perti.

MariaRose

HiPerti
Thanks for your reply, I am going to try it out and give you feedback, should be work the lists content the same amount of elements.
I am wondering that there is no function in a more easier way..

Karim

… If it was not what you were looking for, Just wanted to interlock any 2 lists.
Well you can use interlock. (cf attachment)…
Best
K

rc

Hi,
Here’s another way using mattrans.
note for Karim: interlock is not working if the 2 lists are equal length. 4ex: (3 5 2) (a b c)
Best,
RC

Karim

Good solution RC,
and yes you are right about interlock.
However when using mattrans and unequal list length adding remove at the end of the flat is recommended. (cf screenshot)
BEst
K
Attachments:Screenshot_20171022_182608.png
Screenshot_20171022_182608.png

rc

Correction: interlock works with 2 lists of equal length but it doesn’t include last element. Same example (3 5 2) (a b c) will give (3 a 5 b 2) as a result. Is there an explanation for this?
Best,
RC

Karim

YEs ..
It’s because of the missing last position of the first list. If you add nil at the end of the first list then you can interlock the last elem of the second list (see screenshot). YOu should also remove the nil from the resulting output…. However i find your mattrans solution more elegant and efficient…
Best
K
Attachments:Screenshot_20171022_183615.png
Screenshot_20171022_183615.png

MariaRose

Thanks a lot RC, that was the solution I was searching for!
ps: and Karim of course thanks for ur welcoming me ðŸ˜‰

This reply was modified 3 months, 4 weeks ago by MariaRose.

rc

You’re welcome, and thanks Karim for the explanation!
Best,
RC

perti

thanks both RC an Karim for the proper om solution.
regards,
m.
