< Back to IRCAM Forum

Map Lists

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?

Thanks,
Chris Bailey

… elementaire mon cher Watson …

zip.omp (2.25 KB)

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. :frowning:

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

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.
BEst
K

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?

OOOps

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.

Best
K

cassq.lisp (61 Bytes)

That seems to work.

Thank you very much!!

Chris

Hello,

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.

Best.
RC

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