# Why does Replace /. not get evaluated in this formula?

Learning the wolfram Language, in section 32

"The Wolfram Language" // Characters[#]& /. Alternatives @@Characters["aeiou"] -> Nothing


Returns {T,h,e, ,W,o,l,f,r,a,m, ,L,a,n,g,u,a,g,e}

I expected it to return {T,h, ,W,l,f,r,m, ,L,n,g,g}

Changing it to

Characters["The Wolfram Language"] /. Alternatives @@Characters["aeiou"] -> Nothing


Returns the expected result, why?

• Be careful with afterthought (//) notation. In this case, everything after // is grouped together. You can see this by repeatedly clicking Characters and see how the selection expands. You'd need to write ("The Wolfram Language" // Characters[#]&) /. ... to make this work. Aug 25, 2020 at 20:23
• Related: (30425) Aug 25, 2020 at 20:25

Characters[#] & /. Alternatives @@ Characters["aeiou"] -> Nothing is processed together. You can see this by quadruple-clicking on Characters[#] -- the extended highlighting shows the operator associations and order of processing.

Processing the operations together is equivalent to constructing f, as here:

f = Characters[#] & /. Alternatives @@ Characters["aeiou"] -> Nothing;

"The Wolfram Language" // f


{T,h,e, ,W,o,l,f,r,a,m, ,L,a,n,g,u,a,g,e}

As well as the method you show, the operator binding can be fixed like this:

ReplaceAll["The Wolfram Language" // Characters[#] &,
Alternatives @@ Characters["aeiou"] -> Nothing]


{T,h, ,W,l,f,r,m, ,L,n,g,g}

• I'm on wolfram cloud, does quadruple clicking work there? It seems not to. Also, is there a way to modify execution order with parentheses, etc? Aug 25, 2020 at 20:28
• Ah, this does work: ("The Wolfram Language"//Characters[#]&)/.Alternatives@@Characters["aeiou"]->Nothing Gotcha, that's helpful Aug 25, 2020 at 20:30
• So, essentially, I should think about // not as piping syntax (as I'm used to from shell scripts) but rather as a convenient lambda creator. It takes everything prior to the // and treats it as arguments and everything after // and treats it as a function Aug 25, 2020 at 20:34
• You may find this informative: Special Ways to Input Expressions : i.e. "You should notice that // has very low precedence. " Aug 25, 2020 at 21:03