kill(all)$

maxima : appendix : 'how display chemical reaction : (s)concat',version 1.0
peter.vlasschaert@gmail.com,30/10/2020

load (packages),option
---------------------------------

load(lrats)$ ratprint:false $

? :(S)CONCAT (arg1, arg2, ...)
-------------------------------------------

 a)  Function: CONCAT (arg1, arg2, ...)
===============================
evaluates its arguments and returns the concatenation of their values resulting in a name or a quoted string the type being given by that of the first argument. Thus if X is bound to 1 and D is unbound then CONCAT(X,2)="12" and CONCAT(D,X+1)=D2. 

 b)  Function: SCONCAT (arg1, arg2, ...)
================================

evaluates its arguments and concatenates them into a string. Unlike CONCAT, the arguments do NOT need to be atoms.
The result is a Common Lisp String.
    (C5) sconcat("xx[",3,"]:",expand((x+y)^3));
    (D5) xx[3]:Y^3+3*X*Y^2+3*X^2*Y+X^3

→example :sconcat
================

 sconcat("xx[",3,"]=",(a[2])^2);

eval_string(%);

→example:concat
===============

product : H2SO4
=============

c1:[H[2],S,O[4]];
c1a:string(c1[1].c1[2].c1[3])$

c1b:concat(c1a);

c1c:eval_string(c1b);

product : NaOH
=============

c2:[NA,O,H];
c2a:string(c2[1].c2[2].c2[3])$

c2b:eval_string(%);

product : Na2SO4
==============

c3:[Na[2],S,O[4]];
c3d:eval_string(string(c3[1].c3[2].c3[3]));

product : H2O
==============

c4:[H[2],O];
c4a:product(c4[i],i,1,length(c4));
c4d:eval_string(string(c4a));

c5:[H[2],O];
c5a:c5[1].c5[2];
c5b:eval_string(string(c5a));

final :chemical reaction 
==================
solution →  NaOH +H2SO4 = Na2SO4 + H2O

→  "display the chemical reaction"

2*c2b + c1c = c3d + 2*c5b;

2*c2b + c1c = c3d + 2*c4d;