# how to filter out numbers of specific type in a table

I am working with a way to generate a table of some numbers, but the one functions could return the complex numbers which I don't want. I am going to filter out the complex numbers. The only way I can think of is to use a loop to copy the desired numbers from one list to another

fun1[{a_, b_, c_}] := {a, a*b + c, c};
fun2[a_, b_] := Sqrt[a - a/b];
pval = Table[{2, fun2[3, i], i}, {i, -0.5, 1.5, 0.15}];

pval2 = {};
For[k = 1, k <= Length[pval], k++,
pval2 = Insert[pval2, pval[[k]], Length[pval2] + 1]]]
pval = fun1 /@ pval2


In this code, fun2 might return real or complex number. pval is a table with each elements a list of 3 numbers, the second number of each table element is returned by fun2. I don't want to keep any elements contains complex numbers.

Above code is just an example. In the practical case, the functional form of fun1 and fun2 will be more complicated.

-
take a look here mathematica.stackexchange.com/q/40169/5478 – Kuba Jan 13 '14 at 21:33
thanks a lot. It is so neat and helps :) – user1285419 Jan 13 '14 at 21:50

redtab=Cases[pval, Except[{_, Complex[_, _], _}]];

fun1/@redtab