# Extracting information from list

I have a huge list that looks like this:

list = {8, 12, 201, 0.001, 3, 7, 100
(InterpolatingFunction[{{0., 0.0018}},"<>"][2916/35] +
InterpolatingFunction[{{0., 0.0018}}, "<>"][2916/35]),
23, 44, 11, -0.002}


I want to extract only the numbers, specifically the numbers around 10. I tried using this Select[list, _?(7 <= # <= 13 &)] but it returns an empty list. I think this happens because the list has both numbers and the 100 (InterpolatingFunction... that I want to ignore. I would also be happy just to extract ALL numbers hence ignoring the 100(InterpolatingFunction... elements.

Could you give me some tip please?

• You can use Select[..., NumberQ[#] && 7 <= # <= 13 & ] Commented Mar 13, 2013 at 9:54
• Thank you so much! That makes it! Should I delete the question?
– Sos
Commented Mar 13, 2013 at 10:00
• You should never delete a question because you got an answer (only if your question was over-the-top stupid). It may be useful to others as well. Commented Mar 13, 2013 at 10:13
• Why is that InterpolatingFunctionthere in the first place? Wouldn't you like to have that evaluated to a real number? Commented Mar 13, 2013 at 10:15
• @Sjoerd: list comes as result of integrating a system using NDSolve considering around 4000 combinations of parameters. Some of those combinations do not yield a solution for the integration.. If possible, yes, I would like to have it evaluated to a real number, but the numerical integration doesn't finish until the endtime I allocated, and the endtime of the InterpolatingFunction is far from the desired (e.g. 0.018429 out of the desired 83.3).
– Sos
Commented Mar 13, 2013 at 10:58

Select wants a function as second argument, not a pattern. You can either use Cases or Select with a pure function:

Cases[list, _?(7 <= # <= 13 &)]

Select[list, (7 <= # <= 13)&]

• One more thing: if I want to select the elements of another list otherlist={{1/10,1,1/100,10},{1/100,1,1/100,10},...} that were used as arguments to obtain list={8,12,201,0.001,3,7,100(InterpolatingFunction[{{0.,0.0018}},"<>"][2916/35]+InterpolatingFunction[{{0.,0.0018}},"<>"][2916/35]),23,44,11,-0.002} I thought I could use Pick[otherlist,list,NumberQ[#]&&7<=#<=13&]. Yet, it isn't working and returns that both lists have incompatible shapes. But both lists have the same length..
– Sos
Commented Mar 13, 2013 at 10:09
• @Sosi: same problem the other way round: Pick wants, as Cases, a pattern, not a function. Pick[otherlist,list,_?(NumberQ[#]&&7<=#<=13&)] should work, if both lists really have the same structure. Something that might be a problem is that Pick applies the check to all levels of list, so depending on what exactly is the content you might see the shapes-warning. It then probably is better to create a "selection" list independently: Pick[otherlist, (NumberQ[#] && 7 <= # <= 13) & /@ list] Commented Mar 13, 2013 at 10:22
• I had tried your first suggestion before, but was getting that structure error. The second suggestion works perfectly, I had not thought about using a map! Thanks!
– Sos
Commented Mar 13, 2013 at 10:31
• @Sosi: here is another question which has more information about what I think is the deeper reason for the "incompatible shapes" warning, in case you are interested... Commented Mar 13, 2013 at 17:50