How can I convert the this rule to a list:
input = {1 -> {71.52, 55.33}};
to:
output = {71.52, 55.33}
How can I convert the this rule to a list:
input = {1 -> {71.52, 55.33}};
to:
output = {71.52, 55.33}
For versions before 10.0, use Replace
Replace[1, input]
(* {71.52, 55.33} *)
I prefer to avoid ReplaceAll when Replace is appropriate. ReplaceAll works at all levels in an expression and is thus less predictable (or it makes a bigger mess if there's a bug in my code). Consider if you can potentially have multiple non-atomic keys in the rule list, some of which are sub-parts of others, e.g. {1 -> ..., a[1] -> ...}.
For 10.0 or later versions, use Lookup
Lookup[input, 1]
(* {71.52, 55.33} *)
Lookup is better for this use because it tells you if the key is missing from input.
In general, you can convert list of rules into list of values, in the one of following four ways:
Last @@@ input
input[[All, 2]]
input /. Rule -> (#2 &)
Values@input
it could be convenient to use Association for this, depending on what you are actually doing..
Association[input][1]
{71.52, 55.33}
1 /. input– corey979 Nov 04 '16 at 12:14ReplaceAll[1, input]. But what is the meaning of the expression 1? – lio Nov 04 '16 at 12:58input[[1, 2]]. – Alan Nov 04 '16 at 13:13