Dear members of the community
I trying to improve an algorithm where data is stored in a hash table and where ValueQ is going to be used to operate only over defined elements. The case can be easily exemplified as follows:
-
Let us tabulate some data
Do[f[i] = i, {i, 1, 10, 2}]
clearly if one explores these definition through ValueQ, we obtain ‘True’ for
ValueQ[f[1]]
and ‘False’ for
ValueQ[f[2]]
However, the above do not seem to work within a loop, for instance
Table[If[ValueQ[f[i]], f[i], "No value"], {i, 10}]
In this case the output is
{1, f[2], 3, f[4], 5, f[6], 7, f[8], 9, f[10]}
but I was expecting this to be the following
{1,“No value”,3,“No value”,…}
It seems that ValueQ[] always returns ‘True’ as an output
I am rather confused with this result and I will appreciate any help.
Regards
Jesus Rico