I am now practising using Qiskit. The example of Grover's algorithm in tutorials suggests using logical expression, truth table or circuit to construct the oracle. In most textbooks on quantum computation as far as I have read, they use a function $f$ mapping to 0 or 1 during constructing the oracle. So I want to know if there is any beautiful way to do this with Qiskit. For instance, to find 4 in the array of (3, 4, 5, 6, 8, 2, 7, 1), how to use some $f$ like returning 1 if matched, otherwise 0, to construct the oracle? I know I can obtain a truth table 01000000, but if it's too long to compute, how to use an $f$ directly, without calculating the truth table outside the part of quantum computation?
More generally, if elements in the array to search are obtained in iterations (e.g. in one iterate, I obtain one element $x_i$, which is sum of something else like $\sum_j y_j$), should I complete these iterations before doing Grover's algorithm? Or is it feasible to embed the iterations into quantum computation so that I do not need to traversal all the iterations?
In addition, I use the tutorial from https://github.com/Qiskit/qiskit-community-tutorials/blob/master/optimization/grover.ipynb