Skip to main content
8 of 16
added 33 characters in body
bmf
  • 17k
  • 2
  • 32
  • 68

We define the following lists:

list = {x, x^2, x^3};
rules = {x -> 1, x -> 2, x -> 3};

And then we can run

Inner[ReplaceAll, list, rules, List]
ReplaceAll @@@ Thread[{list, rules}]
Table[list[[i]] /. rules[[i]], {i, Length@rules}]
fnctn = #1 /. #2 & @@@ Transpose@({##}) &;

fnctn[list, rules]
MapIndexed[#^# &, Range@Length@list]
Last /@ Power[List @@@ rules, Range[Length@rules]]
  1. Anyone likes While? I don't but it works
Module[{return = {}, i = 1, end = Length@list},
 While[i <= end,
  AppendTo[return, list[[i]] /. rules[[i]]]; i++]; return]
  1. (I hate myself) using For because...why not?
Module[{return = {}}, For[
  i = 1, i <= Length@list, i++,
  AppendTo[return, list[[i]] /. rules[[i]]]];
 return]
  1. After a lot of trial and error
smthng = {#1 /. #4, #2 /. #5, #3 /. #6} & @@ (## & @@@ {##}) &;
smthng[list, rules]

All of the above give

{1, 4, 27}

bmf
  • 17k
  • 2
  • 32
  • 68