# Why does ToRules return a Sequence?

Why does ToRules return a Sequence expression? Why doesn't it return directly what {ToRules[...]} does now? In what application is having Sequence beneficial here?

Now we have to do x /. {ToRules[...]} instead of x /. ToRules[...]. I would have thought that this is the standard and most common application.

Examples:

ToRules[x == 1 || x == 2]
(* Sequence[{x -> 1}, {x -> 2}] *)

ToRules[x == 1]
(* {x -> 1} *)

ToRules[False]
(* Sequence[] *)

ToRules[True]
(* {} *)

• ReduceReduceToRules returns a list. Jan 21, 2015 at 20:33
• Sometimes it's nice to do something like ToRules /@ solutions. That's the only time I can recall liking the Sequence return value. Jan 21, 2015 at 20:43
• Another value of Sequence is to insert several rules into a list without increasing the dimension of the list (avoiding the need for Flatten): mySeq = Sequence[c -> d, e -> f]; {a -> b, mySeq, c -> d} yields {a -> b, c -> d, e -> f, c -> d}. This can be quite useful. Jan 22, 2015 at 0:46

It is very old function. It was introduced in V1.0 in 1988. It was used in the following way: So Sequence header was very useful. Ref (Section 3.4.2).

I suspect this is a way of letting you know that ToRules doesn't have an appropriate head to use for the conversion. Or put another way when a head isn't supplied Sequence is used by default. Consider:

Delete[{1, 2}, 0]

{1, 2} /. _[x__] :> x

Sequence[1, 2]

Sequence[1, 2]


ToRules converts And to List:

ToRules[a == 1 && b == 2 && c == 3]

{a -> 1, b -> 2, c -> 3}


Perhaps it doesn't make sense to equate List with Or` as well?