This code will break up your formula into a list, the first step in calculating a weight.
You need to add a pass that will insert a default 1 for elements lacking a number.
molar_parser.aia (3.3 KB)
This code will break up your formula into a list, the first step in calculating a weight.
You need to add a pass that will insert a default 1 for elements lacking a number.
Got it, now that I've done that, what's the next step?
Do you have a table loaded, ready for lookup in pairs, with the one or two letter atom names in column 1 and the weight in column 2?
oh, yes
Have you learned how to split the formula into a list of either element names or atom counts, like in my sample?
Learn is definitely a strong word, but I could understand the example very well.
Oh, I just realized, my splitter did not take into account atom counts greater that 9, and would separate digits into list items. Those would need to be combined, in the same pass where I recombine multiletter atom names.
(my dinner awaits, so I leave that to you.)
Alright, hahaha, thanks brother
After you fix that, do another pass backwards from the end to index 2, looking for either pairs of atom names followed by a number, or solitary atom names.
Use a running total, and apply your lookup and multiplication to get a number to add to the running total.
After that, is it over?
I was off by an hour on the dinner, so here's progress:
Depends on how advanced your formulas are.
This does not cover ionization or isotopes or parentheses.
But it's a start.
Sorry for the question, but... I don't know how to implement table elements in blocks, I'm really a beginner. I already have it exported in the media
Upload it here?
I lost patience and got another table from Kaggle, with more elements.
I also fixed a bug in my code for elements lacking counts.
Here is the new complete app:
Thank you so much man, you are a good person. You saved my grade here in high school
Study the code thoroughly.
You don't want your grade to be unfounded.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.