I have a list
s:={1, 2, 4, 7, 8}
and I wish to replace every element in the list with Range[Max[s]]
.
I know that I could replace every element individually using ReplaceAll
by doing
Flatten[s /. {1 -> Range[Max[s]], 2 -> Range[Max[s]],
4 -> Range[Max[s]], 7 -> Range[Max[s]], 8 -> Range[Max[s]]}]
However, s is arbitrary, and I will be using this for lists much longer than s. I would like to be able to perform this with one command, rather than replacing each element individually.
I have tried
s /. s -> Range[Max[s]]
But this just returns the range once. I haven't been able to find anything about replacing every element of a list.