# Operation on sublists with multiple arguments

I have a list and add only the values which are > 0 with:

Total[Cases[mylist, x_ /; x > 0]]


How to do this if I now have a list of sublists?

Map[Total[Cases[???, x_ /; x > 0]], mylistoflists]


I tried to use # (to reference the actual sublist) which doesn't work. I tried ## (to reference all values of the actual sublist) which doesn't work.

So, how can I reference the actual list while iterating over all sublists?

• What exactly have you tried with #? You might want to read reference.wolfram.com/language/tutorial/PureFunctions.html – Szabolcs Jul 9 '18 at 17:26
• It is possible that I do not understand your question. Please give a sample input and the corresponding desired output. E.g. here's an input: mylistoflists = {{-1, 2, -3, 4}, {-4, 3, -2, 1}}. I'll wait with writing an answer until you respond. – Szabolcs Jul 9 '18 at 17:29
• So, what's wrong with Map[Total[Cases[#, x_ /; x > 0]] &, mylistoflists] (notice the &)? Btw., Total[Ramp[mylistoflists], {2}] should be a faster way to accomplish your goals (by a speed factor of 100 or so). – Henrik Schumacher Jul 9 '18 at 17:53
• @HenrikSchumacher Thanks! I was missing the & as I thought Mathematica would implicitly a pure function. Ramp looks good too. Is there a function of the same concept for x <= 0? – Robert M. Münch Jul 10 '18 at 13:50