https://github.com/thunderpoot/cliptoe
Command Line Interactive Periodic Table of Elements in multiple languages
https://github.com/thunderpoot/cliptoe
atoms-in-molecules calculator chemistry color colors colour colours command-line command-line-tool education educational golang molecular molecule periodic-elements periodic-table periodic-table-of-elements perl python telebasic
Last synced: about 2 months ago
JSON representation
Command Line Interactive Periodic Table of Elements in multiple languages
- Host: GitHub
- URL: https://github.com/thunderpoot/cliptoe
- Owner: thunderpoot
- Created: 2021-12-16T22:48:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-28T11:32:59.000Z (about 2 years ago)
- Last Synced: 2024-05-02T04:07:44.708Z (about 1 year ago)
- Topics: atoms-in-molecules, calculator, chemistry, color, colors, colour, colours, command-line, command-line-tool, education, educational, golang, molecular, molecule, periodic-elements, periodic-table, periodic-table-of-elements, perl, python, telebasic
- Language: BASIC
- Homepage:
- Size: 150 KB
- Stars: 17
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
[](https://github.com/thunderpoot/cliptoe/tree/main/golang)
[](https://github.com/thunderpoot/cliptoe/tree/main/web)
[](https://github.com/thunderpoot/cliptoe/tree/main/web)
[](https://github.com/thunderpoot/cliptoe/tree/main/perl)
[](https://github.com/thunderpoot/cliptoe/tree/main/python)
[](https://github.com/thunderpoot/cliptoe/tree/main/telebasic)
# cliptoe
Command Line Periodic Table of Elements
### What is it?
- Highlight elements on Periodic Table
- Parse chemical formulas
- Calculate atomic mass of compoundsWeb-UI also available [here](https://underwood.network/ptoe).
## Usage
```
$ cliptoe -h
Command Line Interactive Periodic Table of ElementsUsage:
cliptoe [atom] show details for element by atomic symbol or number
cliptoe [compound] list elements in compoundOptions:
cliptoe --animate= scroll through colours, speed is
cliptoe --var= set colour variation
cliptoe --ind= set colour start index
cliptoe --label show period and group labels
cliptoe --compounds show list of example compounds
cliptoe --key show colour key
cliptoe --table show table / highlight elements on table
cliptoe --mono disable colours
```## Examples
## Concept
The idea was originally a [TeleBASIC](https://github.com/telehack-foundation/.github/blob/main/basic.md) code-golf exercise, then was ported to Perl.
The example screenshots are from the Perl version.Recreating this program in whatever language has been helpful for me in familiarising myself with syntax,
using the same (fairly naïve) approaches. I plan to add more 'translations' eventually.In Perl, the `ptoe_parse_input` function turns a chemical formula into its component items:
```perl
sub ptoe_parse_input
{
my ( $query ) = @_;# Parse chemical formula, input a string and get an array
# e.g 'H2O' => $VAR1 = [ 'H', '2' ]; $VAR2 = [ 'O', '1' ];my @elem;
while ( $query =~ /([A-Z][a-z]?)([0-9]+)?/g )
{
my $element = $1;
my $many = $2;
$many = '1' if !$many;
push @elem, [ $element, $many ];
}return @elem;
}
```
```
$ cliptoe -d C21H30O2
$VAR1 = [
[
'C',
'21'
],
[
'H',
'30'
],
[
'O',
'2'
]
];$ cliptoe -d NaHCO3
$VAR1 = [
[
'Na',
'1'
],
[
'H',
'1'
],
[
'C',
'1'
],
[
'O',
'3'
]
];
$
```## Caveats / Disclaimer
These programs are only able to handle formulas like `C15H31N3O13P2`, formulas like `Fe2(SO4)3` are not supported (yet).
I'm not a chemist, and there are probably all kinds of bugs / problems that I'm not aware of.
I plan to address any such issues to the best of my ability, but cannot make any promises.## Thanks
[@telnet23](https://github.com/telnet23)
[@kelturio](https://github.com/Kelturio)