# How can I use set-builder notation for creating lists?

I am trying to formalize an algorithm using the set-builder notation. Having an array B of values $$d$$: $$B = [d_1,d_2, \ldots,d_n]$$ For instance, I want to define a new list $$A$$ containing the values $$d$$ that are greater than a value $$h$$. The order is important and there could be also values with the same distances. So the following expression using the set-builder notation is wrong: $$A = \{\ d_i \ |\ d_i \in\ B , \ d_i >h \}$$ Can I use the set-builder notation for creating list of values? So far I though this could be a solution, but I don't know if it is acepted: $$A = (\ d_i \ |\ d_i \in\ B , \ d_i >h )$$

Your original notation $$A = (d_i \mid d_i \in B, d_i > h)$$ is not standard. However, I would likely understand it if it was clear from context that $$A$$ should be an array (or sequence) and that the ordering of $$A$$ matters. Personally I think this notation could be improved by replacing $$d_i \in B$$ with $$1 \leq i \leq n$$; because $$B = [d_1\ \ldots d_n]$$, the fact that $$d_i \in B$$ is essentially redundant, and anyway $$d_i \in B$$ is not really standard notation when $$B$$ is not a set.
An equally formal definition of $$A$$ would be: "$$A$$ is the subsequence of $$B$$ consisting of all entries in $$B$$ which are larger than $$h$$". Since there is less possibility of misunderstanding in this English sentence than in the mathematical expression, this is arguably more formal, not less, even though it is written in natural language rather than in mathematical symbols.