0
$\begingroup$

For a given Mathematica code

 j[bb, a1, a2] //. {j[bb, ll__] -> List[ll].List[b1, b2]} 

I obtain the desired answer which is

 a1 b1 + a2 b2

But having a problem with the error

enter image description here

How one can avoid this error message? For this simple case it work perfectly, but I am worried about for some complicated cases that I am going to deal with.

$\endgroup$
2
  • 4
    $\begingroup$ You should use RuleDelayed. j[bb, a1, a2] //. {j[bb, ll__] :> List[ll] . List[b1, b2]} $\endgroup$ Commented May 5, 2023 at 13:26
  • 2
    $\begingroup$ The problem is that in "->" the RHS is evaluated before it is used. In this case, evaluation has no effect, but triggers a warning, because the RHS looks like a mistake. If you replace "->" with ":>" the RHS is not evaluated before substitution, so the problem does not arise. $\endgroup$ Commented May 5, 2023 at 17:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.