kill(all)$

appendix : chemical equations,single or double symbol:function,version 1.0
peter.vlasschaert@gmail.com,16/02/2021

reason :up and down can't be done, to display : "characters, indices" ( = molecules,before & after)
============================================================================
explain : symbols : 'firstline '
               indices  : ' second line ' we can't go to the first line to display something, 'disp: Maxima'
-----------------------------------------------------------------------------------------------------------------------------------------
→ line display 'Maxima', ( ≠  a graphical display = 'used truebasic (line display or graphical display )

ref: appendix
===========

----------------------------------------------------------------------------------------------------------------------------------------------------
new: 07/02/2021: Appendix :How import chemical elements : Maxima (csv file),version 1.0
download  (Maxima,code)       :appendixchemicalequationshowimportcsvfilechemicalelementsversion1
download  (Maxima,png)         :appendixchemicalequationshowimportcsvfilechemicalelementsversion1outp
download  (sheet,csv)               :elementlist.csv
new: 08/02/2021: Appendix :chemical components : molecular mass ,version 1.0.
download  (Maxima,code)       :appendixmolecularmassfromchemicalelementdataversion1
download  (Maxima,png)         :appendixmolecularmassfromchemicalelementdataversion1outp
new: 09/02/2021: Appendix: chemical  components : oxidation state,version 1.0.
download  (Maxima,code)       :appendixchemicalcomponentoxidationstateversion1final
download  (Maxima,png)         :appendixchemicalcomponentoxidationstateversion1finaloutp
new: 13/02/2021: Appendix: chemical  components :sum,version 1.0.
download  (Maxima,code)       :maximachemicaleqstrdispsumpart4version12021
-----------------------------------------------------------------------------------------------------------------------------------------------------

load packages,options
==================

load(lrats)$ratprint:false$load(stringproc)$

single or double symbol ( = chemical element,see : examples 'below')
==================

vb: list input ( before : reaction)

vb[1]:[Na,1,O,1,H,1];

vb[2]:[H,2,S,1,O,4];

vb:makelist(vb[i],i,1,2);

vb[1][1];

vb[1];
vb[2];

va: list input ( after : reaction)

va[1]:[Na,2,S,1,O,4];
va[2]:[H,2,O,1];

va:makelist(va[i],i,1,2);

→ operator: find chemical element (single charlist ,double charlist)
---------------------------------------------------------------------------------------------

→example : Na ,Cl  (double charlist) :result = 2

s1:charlist(simplode([Na]));
s1a:length(s1);

→example : S,O,H,N,C (single charlist):result =1

s2:charlist(simplode([S]));
s2a:length(s2);

How to find symbols in string '[Na]', result → 1 or 2
---------------------------------------------------------------------

s3:length(charlist(simplode([vb[1][1]])));

s3a:makelist(length(charlist(simplode([vb[1][2*(k-1)+1]]))),
    k,1,length(vb[1])/2);

sb:[];

sb : list of all values of (1 or 2 ) before the reaction
--------------------------------------------------------------------

for i:1 thru 2 do(
sb:endcons(makelist(length(charlist(simplode([vb[i][2*(k-1)+1]]))),
            k,1,length(vb[i])/2),sb)

)$

sb;

make general : function ( before & after reaction)
=====================================
reason :to get position (indices in the reaction)
sba(zi,nup),  zi=va or vb , nup = integer  (nup =N,M = integer)

sba(zi,nup):= block([i,k,ss:[]],
for i:1 thru nup do(
ss:endcons(makelist(length(charlist
  (simplode([zi[i][2*(k-1)+1]]))),
            k,1,length(zi[i])/2),ss)),
return(ss)   
)$

before :reaction : (products = 2=N, vb[i],i=1,2),see above
--------------------------------------------

ss;

sba(vb,2);

ss;/*local : variable list : not avaible outside :sba*/

after  :reaction : (products = 2=M, va[i],i=1,2),see :above
--------------------------------------------

sba(va,2);

ss;

info:

N,M 
appendix : chemical equations,equation,version 1.0 'part5'
peter.vlasschaert@gmail.com,15/02/2021

----------------------------------------------------------------------------------------------------------------------------