kill(all)$

Maxima : intro Formula  , 'version 1.0' ,part: '1'
peter.vlasschaert@gmail.com, 30/10/2019

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

k1a:makelist(k1[i][1],i,1,length(k1));

k1b:makelist(k1[i][2],i,1,length(k1));

k1b1:makelist(if  k1[i][2] =1 
    then  k1[i][2] : "" else  k1[i][2] : k1[i][2],i,1,length(k1)   );

k1c:map(concat,k1a,k1b);

k1c1:maplist(concat,k1a,k1b1);

mp1:concat(k1c1[1],k1c1[2]);

for i:3 thru length(k1) do(
mp1: concat(mp1,k1c1[i])); 

mp1;

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

kaa:makelist(v[i][1],i,1,length(v));
kbb:makelist(v[i][2],i,1,length(v));

kbb1:makelist(if  v[i][2] =1 
    then  v[i][2] : "" else  v[i][2] : v[i][2],i,1,length(v));

kcc1:maplist(concat,kaa,kbb1);

mpp:concat(kcc1[1],kcc1[2]);

for i:3 thru length(v) do(
mpp: concat(mpp,kcc1[i]));

mpp;