1
$\begingroup$

What syntax will allow me to find the maximum values, at a given position, across multiple lists of equal length?

For example, suppose we have three lists l1, l2, and l3:

l1 = {1, 2, 1, 1, 5}

l2 = {2, 1, 1, 4, 5}

l3 = {3, 1, 2, 1, 4}

What syntax can be derived to obtain lmax:

lmax = {3, 2, 2, 4, 5}
$\endgroup$
1
  • $\begingroup$ I made a mistake in column 2. That might have been confusing. I edited lmax. $\endgroup$ – user120911 Sep 10 '19 at 11:26
2
$\begingroup$

One option is to use MapThread:

MapThread[Max, {l1, l2, l3}]

Or Map (/@) after Transpose:

Max /@ ({l1, l2, l3}\[Transpose])
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.