# Pure "Select" function over matrix

I have several lists of tuples in the following shape:

l1 = {{1, 134}, {2, 314}, {3, 164}}


I do want to select, from each list, list elements fulfilling a certain criteria. I am using the following pure function for this (applied here to my first list):

In[508]:= Select[l1, #[[1]] > 2 &]

Out[508]= {{3, 164}}


How can I apply this function to several lists at the same time?

Silly question first: how would you best describe this task? That might help me searching for it in the forums. So far I found no good way of doing it (or possibly have simply not understood it if I came across it).

I would be grateful if anyone could point me the right way. I find the pure function annotation a bit confusing still, so any help is greatly appreciated.

thanks!

mondo

Edit addressing Szabolcs' comment: I do have a solution to filter a single list. I want to filter through all my lists though, without having to apply a for loop (if possible).

• Can you clarify the question a bit? It seems you already have a solution. Are you just asking what this operation is called? Jul 27, 2015 at 9:43
• this search will find similar questions on this site. Jul 27, 2015 at 9:45
• @Szabolcs, added edit above. Jul 27, 2015 at 10:02
• Map, perhaps? (Use Map to apply Select to each list in your list of lists. Select does not have a level specification, so you can't do it without some sort of loop. Maybe some don't think of Map as a loop.) Jul 27, 2015 at 10:06
• Thanks Michael - Mapping was what I had in mind, but I couldn't work out the syntax. MikeLimaOscar's answer below is exactly what I had in mind. Thank you all, this has been recurring in my code and given me a headache for a long time... Jul 27, 2015 at 10:26

You say that you have several lists of tuples so I assume you wish to map your Select to them all like:
Select[#, #[[1]] > 2 &] & /@ {l1, l2, l3}

If you find the nesting of the slots, #, confusing then you could use the explicit form of Function, e.g.
Function[{lst}, Select[lst, Function[{elem}, elem[[1]] > 2]]] /@ {l1, l2, l3}

• @mondo Slot indices access different arguments to a particular anonymous function not different levels in nested functions. This sort of thing is clearer when you use the Function form. Jul 27, 2015 at 10:41