How can this rule
a -> {1, 2, 3}
be transformed into this
{a -> 1, a -> 2, a -> 3}
by way of a function?
Answers 3175 and 10524 only address extracting values from the right-hand side, so (as far as I can tell) this question is distinct.
How can this rule
a -> {1, 2, 3}
be transformed into this
{a -> 1, a -> 2, a -> 3}
by way of a function?
Answers 3175 and 10524 only address extracting values from the right-hand side, so (as far as I can tell) this question is distinct.
Use Thread
Thread[ a -> {1, 2, 3} ]
and
Join @@ Thread /@ {a -> {1, 2, 3}, b -> {4, 5, 6}}
You might also be interested in this.
a -> b
is just an alternate notation for Rule[a,b]
, so you can extract a
using First
, Part
, Extract
, etc. See here: reference.wolfram.com/language/tutorial/PartsOfExpressions.html
$\endgroup$
Thread
to it. If you have x = a -> {1,2,3}
then you can just use Thread[x]
, no need to know what's inside x
, other than that it's a rule with a list on the RHS. Can you give an example input and a corresponding example output? I thought a -> {1, 2, 3}
and {a -> 1, a -> 2, a -> 3}
could be considered such. Thread
takes you from one to the other.
$\endgroup$