# A possible issue in combination of the Infix operator ~ with Sequence [closed]

There are other similar questions on this site about using the Infix operator for more than two arguments, which I have read. But there is one thing that I wasn't able to understand and couldn't figure out why. Consider this line:

#~If~Sequence[2, 3] & /@ {False, True, False}


which gives the output {3, 2, 3} as expected. Now if I understand correctly, Sequence @@ {2, 3} is the same as Sequence[2, 3], but if you put this in the above line:

#~If~(Sequence @@ {2, 3}) & /@ {False, True, False}


it results in {Null, 2, 3, Null}. Why does this happen?

Is there some kind of workaround to make it work? I tried playing around with Hold and its variations without any luck.

## 1 Answer

Look at:

Attributes[If]
(* {HoldRest, Protected} *)


Now consider:

If[#1, Sequence @@ {2, 3}] &


Because of the "HoldRest", the Sequence will not be evaluated as you can see by e.g.:

If[#1, Sequence @@ {2, 3}] &[True]
(* Sequence[2, 3] *)


And the following returns Null:

If[#1, Sequence @@ {2, 3}] &[False]

• Thanks. Therefore #~If~Evaluate[Sequence @@ {2, 3}] & /@ {False, True, False} gives the desired result Dec 9, 2021 at 12:53