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]
Answer
Voting to close, but:
list1 = {3, 2, 1, 0};
list2 = {1, 2, 3, 4};
MapThread[lag[test[[1, #2]], #1] &, {list1, list2}]
Comments
Post a Comment