Here is my list:
collection = {76.6256, 51.9264, 50.238, 14.4203, 80.9205, 12.2036, 2.39568,
38.2747, 12.4422, 29.9621}
collection /. {x_ /; x < 50 -> "F"}
and this gives me
{76.6256, 51.9264, 50.238, "F", 80.9205, "F", "F", "F", "F", "F"}
as expected. But I want to add more rules with ranges like that. I'm not sure how to do this. I've tried:
collection /. {{x_ /; x < 50 -> "F"}, {x_ /; 50 <= x < 56 -> "D"},
{x_ /; 56 <= x < 71 -> "C"}, {x_ /; 71 <= x < 85 -> "B"},
{x_ /; 85 <= x <= 100 -> "A"}}
and that yields
{{76.6256, 51.9264, 50.238, "F", 80.9205, "F", "F", "F", "F", "F"}, {76.6256, "D", "D", 14.4203, 80.9205, 12.2036, 2.39568, 38.2747, 12.4422, 29.9621}, {76.6256, 51.9264, 50.238, 14.4203, 80.9205, 12.2036, 2.39568, 38.2747, 12.4422, 29.9621}, {"B", 51.9264, 50.238, 14.4203, "B", 12.2036, 2.39568, 38.2747, 12.4422, 29.9621}, {76.6256, 51.9264, 50.238, 14.4203, 80.9205, 12.2036, 2.39568, 38.2747, 12.4422, 29.9621}}`
and I've tried a few others which don't even work at all. What is the simplest way of going about this? My real question is, how do I construct a list of rules where I can determine which range (0-50, 50-60, etc.) each number in the list is in?
mylist
of lists,ReplaceAll
(/.
) returns a list of results, one for each list inmylist
. See @belisarius's answer. $\endgroup$