Mapping function onto two lists, simultaneously [duplicate]

This question already has an answer here:

Mapping a pure function with multiple slots [duplicate]

3 answers

I have this function

test=> Is just a list of lists of depth 4
list1={3,2,1,0}
list2={1,2,3,4}
lag[l_List, n_Integer] := Drop[PadLeft[l, Length[l] + n, “Blank”], -n]
lag[test[[1, #2]], #1]&/@list1/@list2

As you can see this does not work, I understand why it does not work, but I have not been able to come up with an solution. What I want to happen is described in the list below. Basically I want list1 to go into slot1 and list2 to go into slot2 stepwise as shown below.

lag[test[[1, 1]], 3]
lag[test[[1, 2]], 2]
lag[test[[1, 3]], 1]
lag[test[[1, 4]], 0]

=================

=================

2 Answers
2

=================

Voting to close, but:

list1 = {3, 2, 1, 0};
list2 = {1, 2, 3, 4};
MapThread[lag[test[[1, #2]], #1] &, {list1, list2}]

  

 

aaaa, thought I came up with a good solution by myself, but yours is better. Would I be correct to state that MapThread is the same as using Map[apply[ —> as I have done?
– ALEXANDER
Sep 18 ’13 at 12:29

  

 

@ALEXANDER test this vb = Transpose[{list1, list2}]; Map[lag[test[[1, #[[2]]]], #[[1]]] &, vb]. In Mathematica you always have a lot of ways to do the same thing.
– Dr. belisarius
Sep 18 ’13 at 12:42

list1 = {3, 2, 1, 0};
list2 = {1, 2, 3, 4};
vb = Transpose[{list1, list2}]
Map[(Apply[lag[test[[1, #2]], #1] &, #1]) &, vb]