Question: What is different when cat is used in a combined statement?

Example: Assume expressions assigned to names

xa, xb, xc := y = x, y = x^2, x = x^3

y = x, y = x^2, x = x^3

(1)

where you want to apply a command (rhs in this example) to all names fitting to a certain scheme (here a and c)

seq(cat(x, i), i = [a, c])

xa, xc

(2)

`~`[rhs]([xa, xc])[]

x, x^3

(3)

Combining (2) and (3) in one line

seq(rhs(cat(x, i)), i = [a, c])

Error, invalid input: rhs received xa, which is not valid for its 1st argument, expr

 

throws an error. Although xa evaluates to an equation

rhs(xa)

x

(4)

and

whattype(cat(x, a))

`=`

(5)

seems to do the same.
I have not worked out what the xa is that rhs is receiving in the one line statement (see error).
Since rhs returns xa it does not look like a delayed evaluation.

 

Besides an explanation of what is going on, I'm interested if there is a way to debug what is passed to rhs?

Download cat_in_nested_statement.mw

Please Wait...