Group Admins

  • Profile picture of Karim
  • Profile picture of Jean


Public Group active 15 hours, 7 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Map Lists

Author 3 Subscribed Users |
Profile photo of zipzappoozoo

Good Morning/Afternoon/Night:

I am trying to do an operation, I am sure someone has done this already. I thought it was in native OM somewhere, but I don’t think so, I can’t find it.

Input List, for example: (2 4 3 3 1 5 5)
Map Source: (1 2 3 4 5)
Map Destinations: (7 8 9 10 11)

RESULT: (8 10 9 9 7 11 11)

Make sense? the first list elements ‘mapped’ from the source to the destination.

1) Is there a function that does this? In a library somewhere? I saw something called SUBST-LIST in the library Profile/Utilities, which looked right, but I can’t get it to work. It just gives me my original list.

2) I was trying to build it from scratch with OM-LOOP, I used MAT-TRANS to make the Source and Destination as pairs: ((1 7)(2 8)(3 9)(4 10)(5 11)) . But then I need some kind of function that treats that as a “dictionary” . . .how do I do that in OM?

Chris Bailey

December 17, 2016 at 18:15 #20259
Profile photo of Karim

… elementaire mon cher Watson ….

  1. zip.omp
  2. zip.omp
December 17, 2016 at 23:22 #20264
Profile photo of zipzappoozoo

Unfortunately I get an error when I Ping the final outlet: “Error while evaluating the box MAPCAR: Cannot take CDR of 1.”

Attached is a screen shot.

I never learned the old-school CDR/CAR stuff in LISP. :(

  1. Screen-Shot-2016-12-17-at-5.53.40-PM


  2. Screen-Shot-2016-12-17-at-5.53.40-PM


December 17, 2016 at 23:56 #20267
Profile photo of Karim

Hi Chris,

This is really weird!
Are you sure you didn’t put a space int the (1 2 3) list ? or something like that… ?
It should work.. Cause this apparently means you have a list of list in your (1 2 3), input and most probably because of the lousy input of OM…

Check it out, by creating a new input…
And report back.

December 18, 2016 at 00:13 #20270
Profile photo of zipzappoozoo

I have tried different things but nothing seems to fix it.

I tried (1 2 3), ((1) (2) (3)), 1 2 3, ((1 2 3)), and just 1.

In the latter case (just 1, not a list) it says: “Value is not of type list”.

But of course, if the input is (1 2 3), then it says “cannot take CDR of 1″.

If the input is ((1 2 3)) . . . .this works, but in the listener I just get: ((cdr (assoc 2 3 :test (function eq))))

I also tried ((1) (2) (3)), but it says, “Error while evaluating the box MAPCAR: syntax error in (1): The call (1) does not match the definition (1 item list).”

Any clues from those results?

December 18, 2016 at 00:30 #20271
Profile photo of Karim


ok , this is once AGAIN an undocumented change in OM…

well i am sending you a patch to replace the CHANGED macro to the original one !

which is this one :

(defun cassq (sym l)
(cdr (assoc sym l)))

Just put the cassq.lisp file in your patches folder inside om , relaunch and try again.
It should work like that.


December 18, 2016 at 00:41 #20272
Profile photo of zipzappoozoo

That seems to work.

Thank you very much!!


December 18, 2016 at 00:53 #20275
Profile photo of rc


Here’s another approach using your input list as indexes for the map destination.
With your example it’s easy to get the indexes, but with other lists you will need to rescale the input in order to get consistent indexes (from 0 to length-1).
So in the attached image u will see both attempts, pure om-vanilla. Let me know if it works for you.


  1. Screenshot_2018-03-05_21-19-10


  2. Screenshot_2018-03-05_21-19-10


March 5, 2018 at 21:36 #25741

You must be logged in to reply to this topic.

Log in now