# Nothing in a Query

In Mathematica 10, Nothing is defined as to automaticaly disappear when used in a list or in an association, and moreover with the property that it returns Nothing when called with any number of arguments.

Consider the following Query:

(Query[f][{1, 2, 3, 4, 5}]

(* f[{1, 2, 3, 4, 5}] *)


Hence, when we use Nothing instead of f, I expected the result to be Nothing[{1,2,3,4,5}], wich evaluates to Nothing. However:

Query[Nothing][{1, 2, 3, 4, 5}]

(* {1, 2, 3, 4, 5} *)


The expression Nothing cannot be used as a part specification, but here it behaves like the part specification All. So is Nothing All in Queries?

• With Trace you will see that Nothing will go though List and disappear. I don't know how to judge this behavior though.
– Kuba
Dec 21 '15 at 14:03
• Query[Nothing] // Normal returns Identity. Jun 24 '16 at 9:53

You can use Query[Nothing][{1, 2, 3}] // Trace to catch a problematic moment:

DatasetQueryPackagePrivatecompile0[
{Nothing},
OptionValue[ Query, {}, {FailureAction, PartBehavior, MissingBehavior}]
]


and subsequent evaluation of {Nothing} to {}, from now on, there will be no trace of Nothing and Identity is called:

 DatasetQueryPackagePrivatecompile0[{}, {"Abort", Automatic, Automatic}]

DatasetOverrideMissing[GeneralUtilitiesChecked[Identity, Identity]]


while ...Checked[Nothing, Identity] could work.

I don't know if that's expected or not.

p.s. if you want to use it as an operator, use Query[Nothing &]

• Yes, this shows where and how Nothing is ignored during the evaluation. Nice to see! Dec 21 '15 at 14:48
 Query[Nothing][{1, 2, 3, 4, 5}]
=
Query[][{1, 2, 3, 4, 5}]
=
{1, 2, 3, 4, 5}


Hope this helps.

• Since Query[Nothing] gives Query[Nothing] I would argue.
– Kuba
Dec 21 '15 at 14:10
• As @Kuba has shown, Nothing does not disappear in Query. Nevertheless, I think you are close to an explanation. I tested the following three cases: Query[1,All,1][{{1}}], Query[1, Nothing,1][{{1}}], Query[1, 1][{{1}}]. It gives me the impression that Nothing is simply ignored during the evaluation. That also answers my question. Nothing is not All. Dec 21 '15 at 14:29