Hello. I'm having a little difficulty understanding the behavior of the Characters
function when I apply a set of rules to it. Let me explain. I can apply it like I have below to create lists of the constituent characters in a string in two different ways producing the same output as shown below. In[1]:= a=Characters["fish"] b="fish" // Characters Out[1]= {"f", "i", "s", "h"} Out[2]= {"f", "i", "s", "h"}
Both ways of applying the function give the same output. In[3]:= a==b Out[3]= True
However, when I apply a rule to both expressions above, only one takes the change. In[4]:= Characters["fish"]/. {"f" -> "d"} "fish" // Characters/. {"f" -> "d"} Out[4]= {"d", "i", "s", "h"} Out[5]= {"f", "i", "s", "h"}
If I apply the same rule to the variables set at the top, the rule is applied in both cases. In[6]:= a/. {"f" -> "d"} b/. {"f" -> "d"} Out[6]= {"d", "i", "s", "h"} Out[7]= {"d", "i", "s", "h"}
My question is shouldn't "fish"//Characters/.{"f"->"d"}
produce {d,i,s,h}
? And if not, what is it that I am missing or not getting?
I have attached this post as a notebook as well.
Thanks. Philip.
Attachments: