Talk:Chemical calculator

From Rosetta Code

The task description needs to be complete, without needing chemistry knowledge. Describe how to perform the calculation; input format; data tables etc. Aim the task at those who know how to program but don't know chemistry, for example. --Paddy3118 (talk) 18:01, 18 March 2019 (UTC)

Might be an idea to specify an element symbol consists of one upper-case letter followed by 0, 1 or 2 lower-case letters, so CH4 is uniquely parsed as 1 atom of element C followed by 4 atoms of element H. (The symbols with two lower case letters are for systematic names of as yet unnamed elements, e.g. Ubn would be the symbol of element 120).

Also (sorry to nit-pick but...) Carbon 12 has exactly 6 protons, 6 neutrons and 6 electrons. --Tigerofdarkness (talk) 21:03, 18 March 2019 (UTC)

I leave three letter names for refactoring later when these substances have been found Thanks for telling me about C-12 and the neutrons. I've update the page. --ChristerNilsson (talk) 22:29, 18 March 2019 (UTC)

Some have been found, and those elements need approval to be (re-)named after confirmation (of existence) has been made by (other?) scientists/chemists/physicists/powers-that-be.     -- Gerard Schildberger (talk) 01:04, 19 March 2019 (UTC)

Gerard, it seems that you think three letter names are unnecessary. Anyway, it's just a matter of changing an if to a while in the parse function. --ChristerNilsson (talk) 02:58, 19 March 2019 (UTC)

I have no idea where you got such a wrong idea.   Where or how did you come to that conclusion?   Three-letter names for elements are necessary for various reasons.     -- Gerard Schildberger (talk) 08:35, 19 March 2019 (UTC)

Gerard, I misunderstood you, and have updated Python to allow for three letter names. --ChristerNilsson (talk) 10:19, 19 March 2019 (UTC)

What to do?

All examples need to be computing the same set of results for comparison (adjusting for floating point issues). You need to add to the task description defining what those are.

(P.S. I do like this task though :-)

--Paddy3118 (talk) 11:48, 19 March 2019 (UTC)

Paddy, what do you think about using three decimals in the result? --ChristerNilsson (talk) 23:13, 19 March 2019 (UTC)

Should I keep the really bloated Python version as a reminder of the progress being done during the process? I'm really happy my understanding of RegEx is better now thanks to RC.--ChristerNilsson (talk) 23:13, 19 March 2019 (UTC)

Mass number and atomic weight

There seems to be some confusion here. The mass number is the total number of nucleons in a nucleus. The standard atomic weight is the average observed weight, and this depends on the relative proportion of isotopes. The integer masses given in the task are actually the mass numbers of the most stable isotopes (they are all radioactive). See the NIST periodic table of the elements for instance.

An interesting extension to the task could be to allow isotopes in the chemical formula.

Eoraptor (talk) 00:13, 20 March 2019 (UTC)