chemql-python 1.7.1__tar.gz → 1.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chemql_python-1.8.0/PKG-INFO +1113 -0
- chemql_python-1.8.0/README.md +1096 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/pyproject.toml +3 -3
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/__init__.py +1550 -23
- chemql_python-1.8.0/src/chemql/algebra/__init__.py +219 -0
- chemql_python-1.8.0/src/chemql/algebra/engine.py +1939 -0
- chemql_python-1.8.0/src/chemql/algebra/helper.py +4361 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/codecql.py +1 -1
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/codecql_gui_core.py +1 -1
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/__init__.py +0 -3
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/__init__.py +3 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/common.py +100 -192
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/main.py +99 -145
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/scatter.py +4 -2
- chemql_python-1.8.0/src/chemql/data_analysis/visualization/svg.py +310 -0
- chemql_python-1.8.0/src/chemql/data_analysis/visualization/web.py +740 -0
- chemql_python-1.8.0/src/chemql/formatter.py +494 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/highlighting.json +4 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/highlighting.py +2 -1
- chemql_python-1.8.0/src/chemql/quantity.py +629 -0
- chemql_python-1.8.0/src/chemql/safety.py +485 -0
- chemql_python-1.8.0/src/chemql/stdlib/async.cql +100 -0
- chemql_python-1.8.0/src/chemql/stdlib/events.cql +111 -0
- chemql_python-1.8.0/src/chemql/stdlib/fp.cql +319 -0
- chemql_python-1.8.0/src/chemql/stdlib/iter.cql +232 -0
- chemql_python-1.8.0/src/chemql/stdlib/pipeline.cql +132 -0
- chemql_python-1.8.0/src/chemql/stdlib/predicates.cql +217 -0
- chemql_python-1.8.0/src/chemql/stdlib/state.cql +211 -0
- chemql_python-1.8.0/src/chemql_python.egg-info/PKG-INFO +1113 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql_python.egg-info/SOURCES.txt +16 -1
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql_python.egg-info/entry_points.txt +1 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql_python.egg-info/requires.txt +0 -1
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_images_and_binary.py +2 -5
- chemql_python-1.8.0/tests/test_lambda_calls_and_algebra.py +111 -0
- chemql_python-1.7.1/PKG-INFO +0 -1197
- chemql_python-1.7.1/README.md +0 -1179
- chemql_python-1.7.1/src/chemql/data_analysis/images.py +0 -79
- chemql_python-1.7.1/src/chemql_python.egg-info/PKG-INFO +0 -1197
- {chemql_python-1.7.1 → chemql_python-1.8.0}/LICENSE +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/setup.cfg +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/__main__.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/build.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/codecqlx.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/colors.json +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/BondEnergies.json +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/MoleculeBonds.json +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/Molecules.json +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/PeriodicTableJSON.json +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/Reactions.json +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/spreadsheet.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/area.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/bar.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/boxplot.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/candlestick.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/heatmap.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/histogram.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/line.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/data_analysis/visualization/pie.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/html/periodic_table.html +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/logo64-macos.png +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/logo64.png +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/README.md +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/bits.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/chem/formula.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/chem.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/ciphers.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/collections.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/colors.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/constants.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/dates.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/datetime.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/decimal.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/encoding.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/finance.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/fmt.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/fractions.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/geometry.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/graphs.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/hashing.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/json.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/maps.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/calculus.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/data.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/inference.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/linalg.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/numbers.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/probability.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math/statistics.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/math.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/pathlib.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/physics.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/random.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/regex.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/sampling.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/sequences.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/sets.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/sql.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/sysinfo.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/tables.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/text/utils.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/text.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/timing.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/units.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql/stdlib/validate.cql +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql_python.egg-info/dependency_links.txt +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/src/chemql_python.egg-info/top_level.txt +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_codecql.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_codecqlx_console.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_codecqlx_fonts.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_codecqlx_icon.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_codecqlx_theme.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_data_analysis.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_external_molecule_lookup.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_function_parameters.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_public_api.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_reactions.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_repl_history.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_stdlib.py +0 -0
- {chemql_python-1.7.1 → chemql_python-1.8.0}/tests/test_structured_types.py +0 -0
|
@@ -0,0 +1,1113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chemql-python
|
|
3
|
+
Version: 1.8.0
|
|
4
|
+
Summary: A chemistry-focused query language and REPL
|
|
5
|
+
Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: prompt_toolkit>=3.0
|
|
10
|
+
Requires-Dist: rich>=13.7
|
|
11
|
+
Requires-Dist: pandas>=2.0
|
|
12
|
+
Requires-Dist: openpyxl>=3.1
|
|
13
|
+
Requires-Dist: xlrd>=2.0
|
|
14
|
+
Provides-Extra: test
|
|
15
|
+
Requires-Dist: pytest>=8.0; extra == "test"
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# ChemQL & CodecQL
|
|
19
|
+
|
|
20
|
+
> A Python-embedded query language and terminal toolchain for chemistry data — with a purpose-built editor, package manager, and standard library.
|
|
21
|
+
|
|
22
|
+
ChemQL is a small language for querying, computing with, and simulating chemistry data (elements, molecules, reactions), layered on a Python runtime. It ships with an interactive REPL, a terminal editor (CodecQL), a desktop editor (CodecQLX), a type system (structs, records, enums), namespaces, modules, a macro/preprocessor system, a package manager, and a standard library.
|
|
23
|
+
|
|
24
|
+
- **Distribution name:** `chemql-python`
|
|
25
|
+
- **Import / CLI name:** `chemql`
|
|
26
|
+
- **Language version:** `1.8.0` (per `chemql.__version__`)
|
|
27
|
+
- **Editor version:** `codecql 0.1.2`
|
|
28
|
+
- **GUI Editor version:** `CodecQLX 1.1.1`
|
|
29
|
+
- **Author:** Mohammad Rakibul Islam
|
|
30
|
+
- **Minimum Python:** **3.12+** (verified with `vermin`)
|
|
31
|
+
- **Registry:** `https://chemqlreg.pythonanywhere.com/`
|
|
32
|
+
|
|
33
|
+
> ⚠️ **Safety:** ChemQL executes embedded Python (`[ ... ]`, `[[[ ... ]]]`) and real shell commands (`` ` ... ` ``, ` ``` ` blocks) with the permissions of the running process. Only run code and packages you trust.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Contents
|
|
38
|
+
|
|
39
|
+
1. [Install](#install)
|
|
40
|
+
2. [Quick start](#quick-start)
|
|
41
|
+
3. [Function values — `fn{...}`](#function-values--fn)
|
|
42
|
+
4. [Symbolic algebra](#symbolic-algebra)
|
|
43
|
+
5. [Core commands](#core-commands)
|
|
44
|
+
6. [Query syntax](#query-syntax)
|
|
45
|
+
7. [Chemistry features](#chemistry-features)
|
|
46
|
+
8. [Data analysis and visualization](#data-analysis-and-visualization)
|
|
47
|
+
9. [Type system](#type-system)
|
|
48
|
+
10. [Namespaces & visibility](#namespaces--visibility)
|
|
49
|
+
11. [Modules](#modules)
|
|
50
|
+
12. [Functions, arguments, macros](#functions-arguments-macros)
|
|
51
|
+
13. [Control flow](#control-flow)
|
|
52
|
+
14. [Error handling](#error-handling)
|
|
53
|
+
15. [Python integration](#python-integration)
|
|
54
|
+
16. [Shell integration](#shell-integration)
|
|
55
|
+
17. [CodecQL — the terminal editor](#codecql--the-terminal-editor)
|
|
56
|
+
18. [CodecQLX — the desktop editor](#codecqlx--the-desktop-editor)
|
|
57
|
+
19. [Standard library](#standard-library)
|
|
58
|
+
20. [Built-in functions](#built-in-functions)
|
|
59
|
+
21. [Package manager](#package-manager)
|
|
60
|
+
22. [License and attribution](#license-and-attribution)
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install chemql-python
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Upgrade:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install --upgrade chemql-python
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Dependencies: `rich`, `pandas`, `openpyxl`, `xlrd`, `prompt_toolkit`.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Quick start
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
$ chemql
|
|
84
|
+
Type help or ? for help
|
|
85
|
+
>>> search elements name like "Hydrogen"
|
|
86
|
+
H (Hydrogen)
|
|
87
|
+
>>> search molecules molecular_weight < 20 sort molecular_weight
|
|
88
|
+
H2 (Hydrogen)
|
|
89
|
+
>>> balance H2 + O2 -> H2O
|
|
90
|
+
2 H2 + O2 -> 2 H2O
|
|
91
|
+
>>> let water = {{ findmol "Water" }}
|
|
92
|
+
>>> water.smiles
|
|
93
|
+
O
|
|
94
|
+
>>> findmol "caffeine" return name formula molecular_weight
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Non-interactive:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
chemql -c 'search elements symbol = "Fe" return name symbol number'
|
|
101
|
+
chemql -f script.cql
|
|
102
|
+
chemql -f script.cql -o out.txt # ANSI-stripped output to a file
|
|
103
|
+
chemql --no-ansi
|
|
104
|
+
chemql --suppress-warnings
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Open a file in the bundled editor:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
chemql edit script.cql
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Function values — `fn{...}`
|
|
116
|
+
|
|
117
|
+
`fn{params -> body}` creates a first-class function value. Parameters are comma-separated names; the body is any expression. Add `{args}` immediately after to call it in-place.
|
|
118
|
+
|
|
119
|
+
```chemql
|
|
120
|
+
// Immediate call
|
|
121
|
+
fn{x -> x * 2}{5} // 10
|
|
122
|
+
|
|
123
|
+
// Assign and call later
|
|
124
|
+
let double = fn{x -> x * 2}
|
|
125
|
+
double{5} // 10
|
|
126
|
+
|
|
127
|
+
// Multi-argument
|
|
128
|
+
fn{a, b -> a + b}{3, 4} // 7
|
|
129
|
+
|
|
130
|
+
// Curried — chain argument groups
|
|
131
|
+
fn{a -> fn{b -> a + b}}{1}{2} // 3
|
|
132
|
+
|
|
133
|
+
// String juxtaposition — "text"name concatenates without +
|
|
134
|
+
fn{name -> "Hello "name}{20} // Hello 20
|
|
135
|
+
fn{name -> "Hello "name}{"Alice"} // Hello Alice
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
String juxtaposition joins a quoted string directly with any plain name or dotted path that follows it. Keywords (`if`, `and`, `in`, ...) are left alone.
|
|
139
|
+
|
|
140
|
+
```chemql
|
|
141
|
+
let who = "Bob"
|
|
142
|
+
"Hi "who // Hi Bob
|
|
143
|
+
"a" if 1 else "b" // a (keyword `if`, not joined)
|
|
144
|
+
"x" in "xyz" // True
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
When a call uses an unknown name as a lambda header, the error message suggests the fix:
|
|
148
|
+
|
|
149
|
+
```chemql
|
|
150
|
+
greet{name -> "Hello "name}
|
|
151
|
+
// Error: Unknown function `greet`.
|
|
152
|
+
// Did you mean `fn{name -> "Hello "name}` or `let greet = fn{name -> "Hello "name}`?
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Higher-order use
|
|
156
|
+
|
|
157
|
+
```chemql
|
|
158
|
+
let square = fn{x -> x * x}
|
|
159
|
+
load fp
|
|
160
|
+
fp::map{square, [1, 2, 3, 4]} // [1, 4, 9, 16]
|
|
161
|
+
fp::filter{fn{x -> x > 2}, [1, 2, 3, 4]}
|
|
162
|
+
fp::reduce{fn{a, b -> a + b}, [1, 2, 3, 4]}
|
|
163
|
+
fp::iterate{fn{x -> x * 2}, 1, 6} // [1, 2, 4, 8, 16, 32]
|
|
164
|
+
|
|
165
|
+
let slope = fn{f -> sym_diff{f, "x"}}
|
|
166
|
+
slope{"x^3 + 2x"} // 3x^2 + 2
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## Symbolic algebra
|
|
172
|
+
|
|
173
|
+
`algebra <maths>` (alias `sym`) hands the rest of the line to the built-in symbolic engine. The text is read as pure maths, so LaTeX such as `\frac{x}{y}` is not rewritten by ChemQL. Symbolic variables are separate from ChemQL `let` variables.
|
|
174
|
+
|
|
175
|
+
```chemql
|
|
176
|
+
algebra let a = 3
|
|
177
|
+
algebra diff x: x^3 + a*x // 3x^2 + 3
|
|
178
|
+
algebra integrate x from 0 to 3: x^2
|
|
179
|
+
algebra solve x^2 - 4 = 0
|
|
180
|
+
algebra solve x + y = 3; x - y = 1
|
|
181
|
+
algebra factor x: x^3 - x
|
|
182
|
+
algebra f(x) = x^2 + 1
|
|
183
|
+
algebra f(3) // 10
|
|
184
|
+
algebra let A = \begin{matrix}1 & 2 \\ 3 & 4\end{matrix}
|
|
185
|
+
algebra det(A)
|
|
186
|
+
algebra inv(A)
|
|
187
|
+
algebra plot x from -5 to 5: sin(x)
|
|
188
|
+
algebra table x=0..5 step 1: x^2
|
|
189
|
+
algebra gcd 12, 18
|
|
190
|
+
algebra factorint 360
|
|
191
|
+
algebra set precision 50
|
|
192
|
+
algebra vars
|
|
193
|
+
algebra reset
|
|
194
|
+
algebra help
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The same operations are available as brace functions that work inside `fn{...}`, `fp::map`, and anywhere else a ChemQL value is expected:
|
|
198
|
+
|
|
199
|
+
| Function | Signature | Example |
|
|
200
|
+
|---|---|---|
|
|
201
|
+
| `sym_eval` | `{expr, values?}` | `sym_eval{"(x^2-1)/(x-1)"}` → `x + 1` |
|
|
202
|
+
| `sym_diff` | `{expr, var?, order?}` | `sym_diff{"x^4", "x", 2}` → `12x^2` |
|
|
203
|
+
| `sym_integrate` | `{expr, var?, lower?, upper?}` | `sym_integrate{"x^2", "x", 0, 3}` → `9` |
|
|
204
|
+
| `sym_solve` | `{eq, ...}` | `sym_solve{"x + y = 3", "x - y = 1"}` |
|
|
205
|
+
| `sym_factor` | `{expr, var?}` | `sym_factor{"x^3 - x", "x"}` → `x(x-1)(x+1)` |
|
|
206
|
+
| `sym_table` | `{expr, var, start, stop, step?}` | `sym_table{"x^2", "x", 0, 3}` |
|
|
207
|
+
| `sym_let` | `{name, expr}` | `sym_let{"a", "2x+1"}` |
|
|
208
|
+
| `sym_define` | `{signature, body}` | `sym_define{"f(x)", "x^2+1"}` |
|
|
209
|
+
| `sym_set` | `{"precision"\|"mode", value}` | `sym_set{"precision", 50}` |
|
|
210
|
+
| `sym_vars` | `{}` | list symbolic variables |
|
|
211
|
+
| `sym_reset` | `{}` | forget all symbolic state |
|
|
212
|
+
|
|
213
|
+
Pass ChemQL values into symbolic expressions with `${...}`:
|
|
214
|
+
|
|
215
|
+
```chemql
|
|
216
|
+
let n = 5
|
|
217
|
+
sym_eval{"x^2 + ${n}"} // x^2 + 5
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Combine with lambdas:
|
|
221
|
+
|
|
222
|
+
```chemql
|
|
223
|
+
let slope = fn{f -> sym_diff{f, "x"}}
|
|
224
|
+
slope{"x^3 + 2x"} // 3x^2 + 2
|
|
225
|
+
|
|
226
|
+
load fp
|
|
227
|
+
fp::map{fn{expr -> sym_diff{expr, "x"}}, ["x^2", "x^3", "sin(x)"]}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
LaTeX environments (`\begin{...}`) must be written on one line. `algebra plot` is blocked by `--sandbox`.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Core commands
|
|
235
|
+
|
|
236
|
+
| Command | Purpose |
|
|
237
|
+
|---|---|
|
|
238
|
+
| `search [first\|last\|all] <source> <conditions> [ops] [return fields]` | Query a data source |
|
|
239
|
+
| `source <elements\|molecules\|reactions>` | Set the default source |
|
|
240
|
+
| `findel <name-or-symbol> [return ...]` | Element lookup |
|
|
241
|
+
| `findmol <name-or-formula> [return ...]` | Molecule lookup (local → PubChem → ChemSpider → NIST) |
|
|
242
|
+
| `findre <name-or-id> [return ...]` | Reaction lookup (local → Rhea → Chempirical) |
|
|
243
|
+
| `balance <reactants> ->\|<-> <products>` | Balance a chemical equation |
|
|
244
|
+
| `react <coefficients><molecules>` | Match a stored reaction under current conditions |
|
|
245
|
+
| `set temperature\|pressure\|catalysts <value>` | Set reaction conditions |
|
|
246
|
+
| `add\|remove catalyst "<name>"` | Modify the catalyst list |
|
|
247
|
+
| `conditions` | Show current T / P / catalysts |
|
|
248
|
+
| `algebra <maths>` / `sym <maths>` | Symbolic algebra |
|
|
249
|
+
| `let <name> = <expr>` / `unset <name>` / `variables` | Bind, remove, list variables |
|
|
250
|
+
| `define NAME <value>` / `@NAME` | Object-like macro |
|
|
251
|
+
| `define NAME{} ... enddefine` / `@NAME{...}` | Function-like macro |
|
|
252
|
+
| `definitions` / `macros` / `remove definition\|macro NAME` | Inspect / remove |
|
|
253
|
+
| `func NAME ... endfunc` | Define a function |
|
|
254
|
+
| `static func Type.method ... endfunc` | Static method |
|
|
255
|
+
| `struct` / `record` / `enum` ... `end*` | Define types |
|
|
256
|
+
| `namespace NAME ... endnamespace` | Group declarations |
|
|
257
|
+
| `load <pkg> [as <alias>]` | Load a package |
|
|
258
|
+
| `load <member> from <pkg> [as <alias>]` | Import one name |
|
|
259
|
+
| `help [topic]` / `?` | Help |
|
|
260
|
+
| `dump [all\|good\|bad] [queries\|results] FILE` | Export history |
|
|
261
|
+
| `view` | Open periodic-table viewer |
|
|
262
|
+
| `clear` / `version` / `exit` | Misc |
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Query syntax
|
|
267
|
+
|
|
268
|
+
**Sources:** `elements`, `molecules`, `reactions`.
|
|
269
|
+
|
|
270
|
+
**Operators:**
|
|
271
|
+
|
|
272
|
+
| Operator | Meaning |
|
|
273
|
+
|---|---|
|
|
274
|
+
| `=` `!=` `>` `<` `>=` `<=` | Comparison |
|
|
275
|
+
| `like` | Case-insensitive wildcard match |
|
|
276
|
+
| `like!` | Case-sensitive wildcard match |
|
|
277
|
+
| `likep` | Regex match |
|
|
278
|
+
| `has` | Nested containment |
|
|
279
|
+
| `and` `or` `not` `( )` | Boolean logic |
|
|
280
|
+
|
|
281
|
+
**`like` wildcards:**
|
|
282
|
+
|
|
283
|
+
| Token | Matches |
|
|
284
|
+
|---|---|
|
|
285
|
+
| `*` | Any characters |
|
|
286
|
+
| `%` | Digits only |
|
|
287
|
+
| `&` | Letters only |
|
|
288
|
+
| `_` | Any single character |
|
|
289
|
+
| `#` | A single digit |
|
|
290
|
+
| `?` | A single letter |
|
|
291
|
+
| `\` | Escape |
|
|
292
|
+
|
|
293
|
+
**Result operations:** `sort FIELD [asc|desc]`, `limit N`, `count`, `return FIELD ...`, `union`, `intersection`.
|
|
294
|
+
|
|
295
|
+
```chemql
|
|
296
|
+
search elements number > 10 and number < 20 return name symbol
|
|
297
|
+
search molecules molecular_weight < 50 sort molecular_weight limit 10
|
|
298
|
+
search reactions reversible = true return name equation source
|
|
299
|
+
search elements name like "H*"
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Chemistry features
|
|
305
|
+
|
|
306
|
+
### Data
|
|
307
|
+
|
|
308
|
+
```chemql
|
|
309
|
+
findel "iron"
|
|
310
|
+
findel Fe
|
|
311
|
+
findmol "caffeine"
|
|
312
|
+
findmol "C8H10N4O2"
|
|
313
|
+
findre "combustion"
|
|
314
|
+
element{Fe, "melting_point"}
|
|
315
|
+
molar_mass{"H2O"} // 18.015
|
|
316
|
+
empirical_formula{"C6H12O6"} // CH2O
|
|
317
|
+
count_atoms{"H2SO4"} // {"H":2,"S":1,"O":4}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### External lookups
|
|
321
|
+
|
|
322
|
+
`findmol` tries local data, then PubChem, ChemSpider, and NIST in sequence. `findre` tries local data, then Rhea and Chempirical. Network access is blocked in `--sandbox` mode.
|
|
323
|
+
|
|
324
|
+
### Balancing
|
|
325
|
+
|
|
326
|
+
```chemql
|
|
327
|
+
balance H2 + O2 -> H2O
|
|
328
|
+
balance Fe + O2 -> Fe2O3
|
|
329
|
+
balance CH4 + O2 -> CO2 + H2O
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### Reaction simulation
|
|
333
|
+
|
|
334
|
+
```chemql
|
|
335
|
+
set temperature 400
|
|
336
|
+
set pressure 10
|
|
337
|
+
add catalyst "V2O5"
|
|
338
|
+
react 2SO2 + O2 -> 2SO3
|
|
339
|
+
conditions
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Chemistry built-ins
|
|
343
|
+
|
|
344
|
+
| Function | Purpose |
|
|
345
|
+
|---|---|
|
|
346
|
+
| `element{symbol, field?}` | Element data |
|
|
347
|
+
| `molar_mass{formula}` | Molar mass in g/mol |
|
|
348
|
+
| `empirical_formula{formula}` | Empirical formula |
|
|
349
|
+
| `count_atoms{formula}` | Atom counts as a dict |
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Data analysis and visualization
|
|
354
|
+
|
|
355
|
+
### Chart types
|
|
356
|
+
|
|
357
|
+
`chart` accepts: `bar`, `line`, `scatter`, `histogram`, `pie`, `donut`, `area`, `box`, `heatmap`, `radar`, `bubble`, `waterfall`, `treemap`, `funnel`, `gantt`, `candlestick`, `sankey`, `sunburst`, `parallel`.
|
|
358
|
+
|
|
359
|
+
```chemql
|
|
360
|
+
let temps = [20, 25, 30, 35, 40]
|
|
361
|
+
let yield_vals = [0.4, 0.6, 0.75, 0.7, 0.55]
|
|
362
|
+
chart{"line", temps, yield_vals}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### Plot from scripts
|
|
366
|
+
|
|
367
|
+
```chemql
|
|
368
|
+
load csv{"data.csv"}
|
|
369
|
+
plot{x, y, title="My Chart", xlabel="Time (s)", ylabel="Signal"}
|
|
370
|
+
heatmap{matrix, colormap="viridis"}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Spreadsheet / GUI dashboard
|
|
374
|
+
|
|
375
|
+
```chemql
|
|
376
|
+
run_spreadsheet_gui{}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Type system
|
|
382
|
+
|
|
383
|
+
### Structs — mutable, methods, inheritance
|
|
384
|
+
|
|
385
|
+
```chemql
|
|
386
|
+
struct Animal
|
|
387
|
+
public name
|
|
388
|
+
public sound
|
|
389
|
+
|
|
390
|
+
func speak{}
|
|
391
|
+
return self.name + " says " + self.sound
|
|
392
|
+
endfunc
|
|
393
|
+
endstruct
|
|
394
|
+
|
|
395
|
+
let dog = Animal{"Rex", "Woof"}
|
|
396
|
+
dog.speak{}
|
|
397
|
+
dog.name = "Buddy"
|
|
398
|
+
|
|
399
|
+
struct Dog extends Animal
|
|
400
|
+
public breed
|
|
401
|
+
|
|
402
|
+
func speak{}
|
|
403
|
+
return self.name + " (" + self.breed + ") barks"
|
|
404
|
+
endfunc
|
|
405
|
+
endstruct
|
|
406
|
+
|
|
407
|
+
let d = Dog{"Rex", "Woof", "Labrador"}
|
|
408
|
+
d.speak{}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Records — immutable, positional, trailing defaults
|
|
412
|
+
|
|
413
|
+
```chemql
|
|
414
|
+
record Point{x, y}
|
|
415
|
+
let p = Point{3, 4}
|
|
416
|
+
p.x // 3
|
|
417
|
+
|
|
418
|
+
record Config{host, port=8080}
|
|
419
|
+
let c = Config{"localhost"}
|
|
420
|
+
c.port // 8080
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Enums — named singletons with payloads
|
|
424
|
+
|
|
425
|
+
```chemql
|
|
426
|
+
enum Color{Red, Green, Blue}
|
|
427
|
+
let c = Color.Red
|
|
428
|
+
c == Color.Red // True
|
|
429
|
+
|
|
430
|
+
enum Shape{Circle{radius}, Rect{w, h}}
|
|
431
|
+
let s = Shape.Circle{5}
|
|
432
|
+
s.radius // 5
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### Summary
|
|
436
|
+
|
|
437
|
+
| Feature | Mutable | Inheritance | Positional | Payload |
|
|
438
|
+
|---|---|---|---|---|
|
|
439
|
+
| `struct` | yes | yes | yes | — |
|
|
440
|
+
| `record` | no | — | yes | — |
|
|
441
|
+
| `enum` | no | — | — | yes |
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Namespaces & visibility
|
|
446
|
+
|
|
447
|
+
```chemql
|
|
448
|
+
namespace geometry
|
|
449
|
+
public func area{r}
|
|
450
|
+
return 3.14159 * r * r
|
|
451
|
+
endfunc
|
|
452
|
+
|
|
453
|
+
private func _helper{}
|
|
454
|
+
return 42
|
|
455
|
+
endfunc
|
|
456
|
+
endnamespace
|
|
457
|
+
|
|
458
|
+
geometry::area{5}
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
`public` members are accessible from outside; `private` members are not. Use `load member from pkg` to bring a name into the current scope.
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
## Modules
|
|
466
|
+
|
|
467
|
+
A `.cql` file is a module. Load it with:
|
|
468
|
+
|
|
469
|
+
```chemql
|
|
470
|
+
load "mymodule.cql"
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
Or install a package and load it:
|
|
474
|
+
|
|
475
|
+
```bash
|
|
476
|
+
chemql install mypackage
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
```chemql
|
|
480
|
+
load mypackage
|
|
481
|
+
mypackage::some_func{"arg"}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Functions, arguments, macros
|
|
487
|
+
|
|
488
|
+
```chemql
|
|
489
|
+
func greet{name, age=10}
|
|
490
|
+
let value = str{name}
|
|
491
|
+
return value, age, arguments
|
|
492
|
+
endfunc
|
|
493
|
+
|
|
494
|
+
greet{"Jacob"} // ("Jacob", 10, ["Jacob", 10])
|
|
495
|
+
greet{age=30, name="Jacob"} // ("Jacob", 30, ["Jacob", 30])
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Declare parameters inside `{}` after the function name. Parameters can be required, have a default (`age=10`), or be optional (`age?`, equivalent to `age=None`). Calls may pass values positionally or by name.
|
|
499
|
+
|
|
500
|
+
`arguments` is a per-call list in declared parameter order. `kwarguments` contains explicitly supplied keyword arguments.
|
|
501
|
+
|
|
502
|
+
```chemql
|
|
503
|
+
func describe{name, age?}
|
|
504
|
+
if age is None
|
|
505
|
+
return "I am " + str{name}
|
|
506
|
+
endif
|
|
507
|
+
return "I am " + str{name} + " and I am " + str{age}
|
|
508
|
+
endfunc
|
|
509
|
+
|
|
510
|
+
describe{name="Jacob"} // "I am Jacob"
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Passing functions as arguments
|
|
514
|
+
|
|
515
|
+
Any `func` and any `fn{...}` value can be passed to another function:
|
|
516
|
+
|
|
517
|
+
```chemql
|
|
518
|
+
func apply_twice{f, x}
|
|
519
|
+
return f{f{x}}
|
|
520
|
+
endfunc
|
|
521
|
+
|
|
522
|
+
apply_twice{fn{x -> x * 2}, 3} // 12
|
|
523
|
+
|
|
524
|
+
func transform{data, mapper, filterer}
|
|
525
|
+
return fp::filter{filterer, fp::map{mapper, data}}
|
|
526
|
+
endfunc
|
|
527
|
+
|
|
528
|
+
transform{[1,2,3,4,5], fn{x -> x*x}, fn{x -> x > 5}}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### Definitions (object-like)
|
|
532
|
+
|
|
533
|
+
```chemql
|
|
534
|
+
define MAX 9
|
|
535
|
+
@MAX * 9 // 81
|
|
536
|
+
print("2@MAX") // "29"
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
### Macros (function-like)
|
|
540
|
+
|
|
541
|
+
```chemql
|
|
542
|
+
define CLAMP{}
|
|
543
|
+
\1 if \1 > 0 else 0
|
|
544
|
+
enddefine
|
|
545
|
+
|
|
546
|
+
@CLAMP{-5} // 0
|
|
547
|
+
@CLAMP{3} // 3
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
---
|
|
551
|
+
|
|
552
|
+
## Control flow
|
|
553
|
+
|
|
554
|
+
```chemql
|
|
555
|
+
if x > 10
|
|
556
|
+
let y = "big"
|
|
557
|
+
elif x > 5
|
|
558
|
+
let y = "medium"
|
|
559
|
+
else
|
|
560
|
+
let y = "small"
|
|
561
|
+
endif
|
|
562
|
+
|
|
563
|
+
for i in range(3)
|
|
564
|
+
print(i)
|
|
565
|
+
endfor
|
|
566
|
+
|
|
567
|
+
while i < 5
|
|
568
|
+
let i = i + 1
|
|
569
|
+
endwhile
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
- `break` / `continue` / `skip` (alias for continue)
|
|
573
|
+
- Bracketed Python-style blocks also accepted: `[for ...] ... [endblock]`
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
## Error handling
|
|
578
|
+
|
|
579
|
+
```chemql
|
|
580
|
+
risk
|
|
581
|
+
signal "Something went wrong"
|
|
582
|
+
fix
|
|
583
|
+
let handled = error
|
|
584
|
+
cleanup
|
|
585
|
+
let finished = true
|
|
586
|
+
endrisk
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
- `signal "msg"` raises a recoverable ChemQL signal
|
|
590
|
+
- `warn "msg"` sets `warnings` and prints (suppress with `--suppress-warnings`)
|
|
591
|
+
- `error` holds the last error type (or `None` after success)
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
## Python integration
|
|
596
|
+
|
|
597
|
+
Inline expression:
|
|
598
|
+
|
|
599
|
+
```chemql
|
|
600
|
+
[1 + 2 * 3] // 7
|
|
601
|
+
[x * 2]
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
Multiline Python block:
|
|
605
|
+
|
|
606
|
+
```chemql
|
|
607
|
+
[[[
|
|
608
|
+
for x in range(3):
|
|
609
|
+
print(x)
|
|
610
|
+
]]]
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
Embedded queries inside Python:
|
|
614
|
+
|
|
615
|
+
```chemql
|
|
616
|
+
let m = [len({{ search molecules molecular_weight < 20 }})]
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
---
|
|
620
|
+
|
|
621
|
+
## Shell integration
|
|
622
|
+
|
|
623
|
+
Inline:
|
|
624
|
+
|
|
625
|
+
```chemql
|
|
626
|
+
`echo hello`
|
|
627
|
+
let files = `ls -1`
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
Multiline:
|
|
631
|
+
|
|
632
|
+
````chemql
|
|
633
|
+
```bash
|
|
634
|
+
echo "Hello from shell"
|
|
635
|
+
ls -la
|
|
636
|
+
```
|
|
637
|
+
````
|
|
638
|
+
|
|
639
|
+
Shell blocks are disabled in `--sandbox` mode.
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## CodecQL — the terminal editor
|
|
644
|
+
|
|
645
|
+
### Starting CodecQL
|
|
646
|
+
|
|
647
|
+
```bash
|
|
648
|
+
chemql edit # blank buffer
|
|
649
|
+
chemql edit script.cql # open a file
|
|
650
|
+
chemql edit script.cql -r # read-only
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
### Key bindings
|
|
654
|
+
|
|
655
|
+
| Key | Action |
|
|
656
|
+
|---|---|
|
|
657
|
+
| `Ctrl+S` | Save |
|
|
658
|
+
| `Ctrl+Q` | Quit |
|
|
659
|
+
| `Ctrl+R` | Run current file |
|
|
660
|
+
| `Ctrl+F` | Find |
|
|
661
|
+
| `Ctrl+H` | Find and replace |
|
|
662
|
+
| `Ctrl+G` | Go to line |
|
|
663
|
+
| `Ctrl+A` | Select all |
|
|
664
|
+
| `Ctrl+C` / `Ctrl+V` / `Ctrl+X` | Copy / Paste / Cut |
|
|
665
|
+
| `Ctrl+Z` / `Ctrl+Y` | Undo / Redo |
|
|
666
|
+
| `Alt+Up/Down` | Move line up/down |
|
|
667
|
+
| `Tab` | Indent / accept suggestion |
|
|
668
|
+
| `Shift+Tab` | Dedent |
|
|
669
|
+
| `F5` | Run |
|
|
670
|
+
| `F6` | Run selection |
|
|
671
|
+
|
|
672
|
+
### Search
|
|
673
|
+
|
|
674
|
+
`Ctrl+F` opens an inline search bar. `Ctrl+H` opens find-and-replace. Both support plain text and regex (`/pattern/` syntax).
|
|
675
|
+
|
|
676
|
+
### Syntax highlighting
|
|
677
|
+
|
|
678
|
+
Highlighting rules live in `highlighting.json` in the ChemQL config directory. The following keyword groups are highlighted: commands (`balance`, `algebra`, `sym`, `react`, `findel`, `findmol`, `findre`, `load`, ...), control flow (`if`, `for`, `while`, `endif`, ...), type keywords (`struct`, `record`, `enum`, ...), and all standard library package names (`fp`, `iter`, `predicates`, `pipeline`, `state`, `events`, `async`, `math`, `text`, `collections`, ...).
|
|
679
|
+
|
|
680
|
+
### Inline suggestions
|
|
681
|
+
|
|
682
|
+
CodecQL shows completions as you type. `Tab` accepts the highlighted suggestion; `Esc` dismisses it. The engine knows about commands, keywords, variables in scope, and loaded package members.
|
|
683
|
+
|
|
684
|
+
### Configuration: `highlighting.json`
|
|
685
|
+
|
|
686
|
+
```json
|
|
687
|
+
{
|
|
688
|
+
"keywords": { "color": "cyan" },
|
|
689
|
+
"strings": { "color": "green" },
|
|
690
|
+
"comments": { "color": "bright_black" },
|
|
691
|
+
"numbers": { "color": "yellow" }
|
|
692
|
+
}
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### CodecQL known limitations
|
|
696
|
+
|
|
697
|
+
- No LSP or external formatter integration
|
|
698
|
+
- Terminal emulator must support 256 colors or true color for best results
|
|
699
|
+
- Very large files (> 50 000 lines) may be slow to load
|
|
700
|
+
|
|
701
|
+
---
|
|
702
|
+
|
|
703
|
+
## CodecQLX — the desktop editor
|
|
704
|
+
|
|
705
|
+
CodecQLX is the cross-platform GUI editor for ChemQL, wrapping CodecQL in a native window with a menu bar, file tabs, and an integrated terminal.
|
|
706
|
+
|
|
707
|
+
### Starting CodecQLX
|
|
708
|
+
|
|
709
|
+
```bash
|
|
710
|
+
chemql gui # launch the GUI
|
|
711
|
+
chemql gui script.cql # open a file
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
### Features
|
|
715
|
+
|
|
716
|
+
- Syntax-highlighted editor (uses the same `highlighting.json` as CodecQL)
|
|
717
|
+
- File tabs; reopen recent files from **File → Recent**
|
|
718
|
+
- Integrated terminal; runs `chemql` automatically
|
|
719
|
+
- Split-pane output view
|
|
720
|
+
- Settings dialog for font size, theme, and auto-save interval
|
|
721
|
+
- **Run** toolbar button, also bound to `F5`
|
|
722
|
+
|
|
723
|
+
### Keyboard shortcuts
|
|
724
|
+
|
|
725
|
+
| Shortcut | Action |
|
|
726
|
+
|---|---|
|
|
727
|
+
| `Ctrl+N` | New file |
|
|
728
|
+
| `Ctrl+O` | Open |
|
|
729
|
+
| `Ctrl+S` | Save |
|
|
730
|
+
| `Ctrl+Shift+S` | Save as |
|
|
731
|
+
| `Ctrl+W` | Close tab |
|
|
732
|
+
| `F5` | Run |
|
|
733
|
+
| `Ctrl+F` | Find |
|
|
734
|
+
| `Ctrl+H` | Replace |
|
|
735
|
+
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
## Standard library
|
|
739
|
+
|
|
740
|
+
Load with `load <pkg>`; call as `<pkg>::name{...}`. Use `help{stdlib}` to list all packages, `help{fp}` for a category, and `help{fp::map}` for a single function.
|
|
741
|
+
|
|
742
|
+
### Core packages
|
|
743
|
+
|
|
744
|
+
| Package | Purpose |
|
|
745
|
+
|---|---|
|
|
746
|
+
| `math` | Constants, trigonometry, logarithms, number theory |
|
|
747
|
+
| `math::statistics` | Mean, median, mode, variance, std dev, quantiles |
|
|
748
|
+
| `math::calculus` | Numerical differentiation and integration |
|
|
749
|
+
| `math::probability` | Combinatorics and distributions |
|
|
750
|
+
| `math::linalg` | Vectors, matrices, norms |
|
|
751
|
+
| `math::inference` | Hypothesis tests, confidence intervals |
|
|
752
|
+
| `text` | String transforms, splitting/joining, regex helpers |
|
|
753
|
+
| `collections` | Uniqueness, flattening, pairing, frequency counts |
|
|
754
|
+
| `sequences` | Slicing, windowing, zipping |
|
|
755
|
+
| `maps` | Dict merging, inversion, filtering |
|
|
756
|
+
| `tables` | Tabular data manipulation |
|
|
757
|
+
| `datetime` | Dates, timestamps, local/UTC time, date arithmetic |
|
|
758
|
+
| `json` | JSON encode/decode helpers |
|
|
759
|
+
| `random` | Pseudo-random numbers and sequence sampling |
|
|
760
|
+
| `decimal` | Base-10 decimal arithmetic and quantization |
|
|
761
|
+
| `fractions` | Exact rational numbers and fraction arithmetic |
|
|
762
|
+
| `pathlib` | Path inspection and UTF-8 text file operations |
|
|
763
|
+
|
|
764
|
+
### `fp` — Functional programming
|
|
765
|
+
|
|
766
|
+
Requires `fn{...}`. Load with `load fp`.
|
|
767
|
+
|
|
768
|
+
```chemql
|
|
769
|
+
load fp
|
|
770
|
+
|
|
771
|
+
// Transform
|
|
772
|
+
fp::map{fn{x -> x * 2}, [1, 2, 3]} // [2, 4, 6]
|
|
773
|
+
fp::filter{fn{x -> x > 2}, [1, 2, 3, 4]} // [3, 4]
|
|
774
|
+
fp::reject{fn{x -> x > 2}, [1, 2, 3, 4]} // [1, 2]
|
|
775
|
+
fp::flat_map{fn{x -> [x, x*2]}, [1, 2, 3]} // [1, 2, 2, 4, 3, 6]
|
|
776
|
+
fp::zip_with{fn{a, b -> a + b}, [1,2,3], [4,5,6]}
|
|
777
|
+
fp::zip_into{fn{a, b -> a * b}, [[1,2,3],[4,5,6]]}
|
|
778
|
+
fp::apply_map{fn{a, b -> a + b}, [[1,4],[2,5],[3,6]]}
|
|
779
|
+
|
|
780
|
+
// Accumulate
|
|
781
|
+
fp::reduce{fn{a, b -> a + b}, [1, 2, 3, 4]} // 10
|
|
782
|
+
fp::scan{fn{a, b -> a + b}, [1, 2, 3, 4]} // [1, 3, 6, 10]
|
|
783
|
+
|
|
784
|
+
// Group and count
|
|
785
|
+
fp::group_by{fn{x -> x % 2}, [1, 2, 3, 4, 5]} // {"1":[1,3,5],"0":[2,4]}
|
|
786
|
+
fp::count_by{fn{x -> x % 2}, [1, 2, 3, 4, 5]}
|
|
787
|
+
fp::partition{fn{x -> x > 2}, [1, 2, 3, 4]} // [[3,4],[1,2]]
|
|
788
|
+
|
|
789
|
+
// Search
|
|
790
|
+
fp::find{fn{x -> x > 3}, [1, 2, 3, 4, 5]} // 4
|
|
791
|
+
fp::find_index{fn{x -> x > 3}, [1, 2, 3, 4, 5]}
|
|
792
|
+
fp::sort_by{fn{x -> -x}, [3, 1, 4, 1, 5]} // [5,4,3,1,1]
|
|
793
|
+
fp::min_by{fn{x -> abs(x)}, [-5, 3, -1, 4]} // -1
|
|
794
|
+
fp::max_by{fn{x -> abs(x)}, [-5, 3, -1, 4]} // -5
|
|
795
|
+
|
|
796
|
+
// Test
|
|
797
|
+
fp::all{fn{x -> x > 0}, [1, 2, 3]} // True
|
|
798
|
+
fp::any{fn{x -> x > 4}, [1, 2, 3, 4, 5]}
|
|
799
|
+
fp::none{fn{x -> x > 10}, [1, 2, 3]}
|
|
800
|
+
fp::take_while{fn{x -> x < 4}, [1, 2, 3, 4, 5]}
|
|
801
|
+
fp::drop_while{fn{x -> x < 3}, [1, 2, 3, 4, 5]}
|
|
802
|
+
|
|
803
|
+
// Sequence building
|
|
804
|
+
fp::iterate{fn{x -> x * 2}, 1, 5} // [1, 2, 4, 8, 16]
|
|
805
|
+
fp::pipe{3, [fn{x -> x+1}, fn{x -> x*2}]} // 8
|
|
806
|
+
|
|
807
|
+
// Combinators
|
|
808
|
+
let double_then_inc = fp::compose{fn{x -> x+1}, fn{x -> x*2}}
|
|
809
|
+
double_then_inc{3} // 7
|
|
810
|
+
|
|
811
|
+
let fast_sq = fp::memoize{fn{x -> x * x}}
|
|
812
|
+
fast_sq{7} // 49 (cached across calls)
|
|
813
|
+
|
|
814
|
+
let flip_sub = fp::flip{fn{a, b -> a - b}}
|
|
815
|
+
flip_sub{10, 3} // -7 (arguments reversed)
|
|
816
|
+
|
|
817
|
+
let const42 = fp::constantly{42}
|
|
818
|
+
const42{1, 2, 3} // 42 (ignores its arguments)
|
|
819
|
+
|
|
820
|
+
fp::identity{99} // 99
|
|
821
|
+
fp::apply{fn{a, b, c -> a+b+c}, [1, 2, 3]} // 6
|
|
822
|
+
fp::juxt{[fn{x->x+1}, fn{x->x*2}], 3} // [4, 6]
|
|
823
|
+
fp::each{fn{x -> print(x)}, [1, 2, 3]}
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
### `iter` — Iteration
|
|
827
|
+
|
|
828
|
+
Lazy-style iteration; all output is a plain list. Load with `load iter`.
|
|
829
|
+
|
|
830
|
+
```chemql
|
|
831
|
+
load iter
|
|
832
|
+
|
|
833
|
+
// Generating sequences
|
|
834
|
+
iter::generate{fn{x -> x*2}, 1, 6} // [1, 2, 4, 8, 16, 32]
|
|
835
|
+
iter::generate_while{fn{x -> x*2}, 1, fn{x -> x < 50}}
|
|
836
|
+
iter::tabulate{fn{i -> i*i}, 5} // [0, 1, 4, 9, 16]
|
|
837
|
+
iter::unfold{fn{n -> [n, n+1] if n < 5 else None}, 0, 10}
|
|
838
|
+
iter::cycle{[1, 2, 3], 7} // [1,2,3,1,2,3,1]
|
|
839
|
+
iter::apply_n{fn{x -> x+1}, 0, 5} // 5
|
|
840
|
+
|
|
841
|
+
// Reshaping
|
|
842
|
+
iter::enumerate_list{["a","b","c"]} // [[0,"a"],[1,"b"],[2,"c"]]
|
|
843
|
+
iter::zip_map{["a","b","c"], [1,2,3]} // {"a":1,"b":2,"c":3}
|
|
844
|
+
iter::chain{[[1,2],[3,4],[5]]} // [1,2,3,4,5]
|
|
845
|
+
iter::distinct_by{fn{x -> x % 3}, [1,2,3,4,5,6]}
|
|
846
|
+
iter::split_by{fn{x -> x == 0}, [1,2,0,3,4,0,5]}
|
|
847
|
+
|
|
848
|
+
// Windowed operations
|
|
849
|
+
iter::window_map{fn{w -> w[0]+w[1]}, [1,2,3,4], 2}
|
|
850
|
+
iter::sliding_reduce{fn{a,b -> a+b}, [1,2,3,4,5], 3}
|
|
851
|
+
iter::batch_map{fn{b -> sum(b)}, [1,2,3,4,5,6], 2}
|
|
852
|
+
|
|
853
|
+
// Compression
|
|
854
|
+
iter::run_length{[1,1,2,3,3,3]} // [[1,2],[2,1],[3,3]]
|
|
855
|
+
iter::run_length_decode{[[1,2],[2,1],[3,3]]} // [1,1,2,3,3,3]
|
|
856
|
+
|
|
857
|
+
// Side effects without changing values
|
|
858
|
+
iter::tee{fn{x -> print(x)}, [1,2,3]}
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
### `predicates` — Predicate combinators
|
|
862
|
+
|
|
863
|
+
Build reusable filter functions that compose cleanly. Load with `load predicates`.
|
|
864
|
+
|
|
865
|
+
```chemql
|
|
866
|
+
load predicates
|
|
867
|
+
load fp
|
|
868
|
+
|
|
869
|
+
// Comparison predicates
|
|
870
|
+
fp::filter{predicates::greater_than{3}, [1, 2, 3, 4, 5]}
|
|
871
|
+
fp::filter{predicates::less_than{3}, [1, 2, 3, 4, 5]}
|
|
872
|
+
fp::filter{predicates::between{2, 4}, [1, 2, 3, 4, 5]}
|
|
873
|
+
fp::filter{predicates::equals{3}, [1, 2, 3, 4, 5]}
|
|
874
|
+
|
|
875
|
+
// String predicates
|
|
876
|
+
fp::filter{predicates::has_prefix{"he"}, ["hello","world","hey"]}
|
|
877
|
+
fp::filter{predicates::has_suffix{".py"}, ["foo.py","bar.js"]}
|
|
878
|
+
fp::filter{predicates::contains{"ell"}, ["hello","world"]}
|
|
879
|
+
fp::filter{predicates::matches{"[0-9]+"}, ["abc","123","4x"]}
|
|
880
|
+
|
|
881
|
+
// Collection predicates
|
|
882
|
+
fp::filter{predicates::is_in{[1, 3, 5]}, [1, 2, 3, 4, 5]}
|
|
883
|
+
fp::filter{predicates::not_in{[1, 3, 5]}, [1, 2, 3, 4, 5]}
|
|
884
|
+
fp::filter{predicates::length_at_least{3}, ["a","ab","abc","abcd"]}
|
|
885
|
+
fp::filter{predicates::has_key{"name"}, [{"name":"Bob"},{"age":5}]}
|
|
886
|
+
|
|
887
|
+
// Dict field predicates
|
|
888
|
+
fp::filter{predicates::key_satisfies{"age", predicates::greater_than{18}},
|
|
889
|
+
[{"age":15},{"age":25},{"age":30}]}
|
|
890
|
+
|
|
891
|
+
// Type predicates
|
|
892
|
+
fp::filter{predicates::is_type{"int"}, [1, "a", 2.0, True]}
|
|
893
|
+
fp::filter{predicates::is_not_none{}, [1, None, 2, None, 3]}
|
|
894
|
+
|
|
895
|
+
// Logical combinators
|
|
896
|
+
let adult = predicates::greater_or_equal{18}
|
|
897
|
+
let teen = predicates::between{13, 17}
|
|
898
|
+
let minor = predicates::not_pred{adult}
|
|
899
|
+
let teenager_or_older = predicates::or_pred{teen, adult}
|
|
900
|
+
let all_checks = predicates::all_pred{[predicates::greater_than{0}, predicates::less_than{100}]}
|
|
901
|
+
|
|
902
|
+
fp::filter{minor, [10, 15, 18, 25]}
|
|
903
|
+
fp::filter{all_checks, [-1, 0, 50, 100, 101]}
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
All builders: `equals`, `not_equals`, `greater_than`, `greater_or_equal`, `less_than`, `less_or_equal`, `between`, `is_in`, `not_in`, `has_prefix`, `has_suffix`, `contains`, `matches`, `is_type`, `is_none`, `is_not_none`, `is_truthy`, `is_falsy`, `has_key`, `length_equals`, `length_at_least`, `length_at_most`, `not_pred`, `and_pred`, `or_pred`, `all_pred`, `any_pred`, `key_satisfies`.
|
|
907
|
+
|
|
908
|
+
### `pipeline` — Data pipelines
|
|
909
|
+
|
|
910
|
+
Build and run named multi-step transformations. Load with `load pipeline`.
|
|
911
|
+
|
|
912
|
+
```chemql
|
|
913
|
+
load pipeline
|
|
914
|
+
|
|
915
|
+
// Define steps: pipeline::step{name, fn}
|
|
916
|
+
let clean = pipeline::step{"strip", fn{s -> s.strip()}}
|
|
917
|
+
let upper = pipeline::step{"upper", fn{s -> s.upper()}}
|
|
918
|
+
let exclaim = pipeline::step{"exclaim", fn{s -> s+"!"}}
|
|
919
|
+
let steps = [clean, upper, exclaim]
|
|
920
|
+
|
|
921
|
+
// Run
|
|
922
|
+
pipeline::run{steps, " hello "} // "HELLO!"
|
|
923
|
+
pipeline::run_each{steps, [" hi "," world "]}
|
|
924
|
+
pipeline::run_traced{steps, " hello "} // {result, trace:[{step,output},...]}
|
|
925
|
+
|
|
926
|
+
// Build up pipelines
|
|
927
|
+
let steps2 = pipeline::append_step{steps, "length", fn{s -> len(s)}}
|
|
928
|
+
let steps3 = pipeline::prepend_step{steps, "lower", fn{s -> s.lower()}}
|
|
929
|
+
let all = pipeline::concat_pipelines{steps, steps2}
|
|
930
|
+
pipeline::step_names{steps} // ["strip","upper","exclaim"]
|
|
931
|
+
|
|
932
|
+
// Branching and looping
|
|
933
|
+
pipeline::run_conditional{fn{x -> x > 0}, positive_steps, negative_steps, value}
|
|
934
|
+
pipeline::run_while{fn{x -> x < 100}, steps, 1}
|
|
935
|
+
pipeline::run_until{fn{x -> x > 1000}, steps, 1}
|
|
936
|
+
|
|
937
|
+
// Same data through several pipelines at once
|
|
938
|
+
pipeline::run_parallel{[steps, steps2], " hello "}
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
`run_traced` returns `{result, trace}` where `trace` is a list of `{step, output}` dicts, one per step. If a step raises an error it records `{step, error}` and stops.
|
|
942
|
+
|
|
943
|
+
### `state` — Mutable state
|
|
944
|
+
|
|
945
|
+
Atoms (single values) and stores (key-value dicts), both thread-safe, with optional validators and change watchers. Load with `load state`.
|
|
946
|
+
|
|
947
|
+
```chemql
|
|
948
|
+
load state
|
|
949
|
+
|
|
950
|
+
// Atom — a single mutable value
|
|
951
|
+
let counter = state::atom{0}
|
|
952
|
+
state::deref{counter} // 0
|
|
953
|
+
state::swap{counter, fn{x -> x + 1}} // 1
|
|
954
|
+
state::swap{counter, fn{x -> x + 1}} // 2
|
|
955
|
+
state::reset_atom{counter, 10} // 10
|
|
956
|
+
state::deref{counter} // 10
|
|
957
|
+
|
|
958
|
+
// Validator — new value must satisfy the predicate
|
|
959
|
+
let positive = state::atom{0, fn{x -> x >= 0}}
|
|
960
|
+
state::reset_atom{positive, 5} // 5
|
|
961
|
+
state::reset_atom{positive, -1} // Error: failed validator
|
|
962
|
+
|
|
963
|
+
// Watch for changes
|
|
964
|
+
state::watch{counter, fn{old, new -> print("changed: "old" -> "new)}}
|
|
965
|
+
state::unwatch{counter, handler}
|
|
966
|
+
|
|
967
|
+
// Store — key-value dictionary
|
|
968
|
+
let init = {"host": "localhost", "port": 8080}
|
|
969
|
+
let cfg = state::store{init}
|
|
970
|
+
state::store_get{cfg, "host"} // "localhost"
|
|
971
|
+
state::store_set{cfg, "debug", True}
|
|
972
|
+
state::store_update{cfg, {"port": 9000, "timeout": 30}}
|
|
973
|
+
state::store_delete{cfg, "debug"}
|
|
974
|
+
state::store_all{cfg} // full snapshot as a dict
|
|
975
|
+
|
|
976
|
+
// Computed value derived from several atoms (call to recompute)
|
|
977
|
+
let x = state::atom{3}
|
|
978
|
+
let y = state::atom{4}
|
|
979
|
+
state::computed{fn{a, b -> a + b}, [x, y]} // 7
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
> **Note on dict literals:** pass the initial dict for a store through a variable — `let d = {...}` then `state::store{d}` — rather than `state::store{{"key": "val"}}`, which triggers ChemQL's template syntax.
|
|
983
|
+
|
|
984
|
+
### `events` — Event bus
|
|
985
|
+
|
|
986
|
+
In-process publish/subscribe. Load with `load events`.
|
|
987
|
+
|
|
988
|
+
```chemql
|
|
989
|
+
load events
|
|
990
|
+
load state
|
|
991
|
+
|
|
992
|
+
let last_temp = state::atom{None}
|
|
993
|
+
|
|
994
|
+
// Subscribe
|
|
995
|
+
events::subscribe{"temperature.changed", fn{t -> state::reset_atom{last_temp, t}}}
|
|
996
|
+
|
|
997
|
+
// One-shot handler
|
|
998
|
+
events::once{"startup", fn{data -> print("started: "data)}}
|
|
999
|
+
|
|
1000
|
+
// Publish
|
|
1001
|
+
events::publish{"temperature.changed", 42.5}
|
|
1002
|
+
state::deref{last_temp} // 42.5
|
|
1003
|
+
|
|
1004
|
+
// Batch publish: each item is [event] or [event, data]
|
|
1005
|
+
events::publish_many{[["a.fired"], ["b.fired", 99]]}
|
|
1006
|
+
|
|
1007
|
+
// Inspect
|
|
1008
|
+
events::subscribers{"temperature.changed"} // 1
|
|
1009
|
+
events::log{10} // last 10 events [{event, data}]
|
|
1010
|
+
events::clear_log{}
|
|
1011
|
+
events::unsubscribe{"temperature.changed"} // remove all handlers for event
|
|
1012
|
+
events::unsubscribe{"temperature.changed", handler} // remove one handler
|
|
1013
|
+
events::reset{} // clear everything
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
### `async` — Concurrent execution
|
|
1017
|
+
|
|
1018
|
+
Runs functions in a thread pool. All functions must be zero-argument (`fn{-> expr}`) for `run_all` and `race`; `parallel_map` and `parallel_filter` supply the argument automatically. Load with `load async`.
|
|
1019
|
+
|
|
1020
|
+
```chemql
|
|
1021
|
+
load async
|
|
1022
|
+
|
|
1023
|
+
// Parallel map and filter
|
|
1024
|
+
async::parallel_map{fn{x -> x * 2}, [1, 2, 3, 4]} // [2, 4, 6, 8]
|
|
1025
|
+
async::parallel_filter{fn{x -> x % 2 == 0}, [1,2,3,4,5,6]} // [2,4,6]
|
|
1026
|
+
async::parallel_all{fn{x -> x > 0}, [1, 2, 3]}
|
|
1027
|
+
async::parallel_any{fn{x -> x > 4}, [1, 2, 3, 4, 5]}
|
|
1028
|
+
|
|
1029
|
+
// Run several tasks at once
|
|
1030
|
+
async::run_all{[fn{-> fetch_a{}}, fn{-> fetch_b{}}, fn{-> fetch_c{}}]}
|
|
1031
|
+
|
|
1032
|
+
// Race to the first result
|
|
1033
|
+
async::race{[fn{-> slow_a{}}, fn{-> fast_b{}}]}
|
|
1034
|
+
|
|
1035
|
+
// Timeout guard
|
|
1036
|
+
async::with_timeout{fn{-> long_task{}}, 5.0}
|
|
1037
|
+
|
|
1038
|
+
// Measure elapsed time
|
|
1039
|
+
let result = async::timed{fn{-> heavy_computation{}}}
|
|
1040
|
+
result[0] // return value
|
|
1041
|
+
result[1] // elapsed seconds
|
|
1042
|
+
|
|
1043
|
+
// Map with index exposed
|
|
1044
|
+
async::parallel_map_indexed{fn{i, x -> str{i}+": "+str{x}}, ["a","b","c"]}
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
---
|
|
1048
|
+
|
|
1049
|
+
## Built-in functions
|
|
1050
|
+
|
|
1051
|
+
### General
|
|
1052
|
+
|
|
1053
|
+
`abs round min max sum len type str int float bool upper lower contains replace split join first last unique sort reversed`
|
|
1054
|
+
|
|
1055
|
+
### File I/O
|
|
1056
|
+
|
|
1057
|
+
`read_text read_lines read_json read_csv write_text write_csv write_json file_exists list_files`
|
|
1058
|
+
|
|
1059
|
+
### Chemistry
|
|
1060
|
+
|
|
1061
|
+
`element count_atoms molar_mass empirical_formula`
|
|
1062
|
+
|
|
1063
|
+
### Symbolic algebra (brace-call form)
|
|
1064
|
+
|
|
1065
|
+
`sym_eval sym_diff sym_integrate sym_solve sym_factor sym_table sym_let sym_define sym_set sym_vars sym_reset`
|
|
1066
|
+
|
|
1067
|
+
### Help
|
|
1068
|
+
|
|
1069
|
+
```chemql
|
|
1070
|
+
help{} // overview by category
|
|
1071
|
+
help{fp} // all fp functions
|
|
1072
|
+
help{fp::map} // one function
|
|
1073
|
+
help{algebra} // algebra command reference
|
|
1074
|
+
help{stdlib} // all packages
|
|
1075
|
+
help{struct} // type system
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
---
|
|
1079
|
+
|
|
1080
|
+
## Package manager
|
|
1081
|
+
|
|
1082
|
+
```bash
|
|
1083
|
+
chemql install <name> [--version V]
|
|
1084
|
+
chemql upgrade <name> [--version V]
|
|
1085
|
+
chemql uninstall <name>
|
|
1086
|
+
chemql list
|
|
1087
|
+
chemql search <query>
|
|
1088
|
+
chemql info <name>
|
|
1089
|
+
chemql build # requires cqlpackage.json / cqlpackage.toml
|
|
1090
|
+
chemql upload # publish to the registry
|
|
1091
|
+
chemql init [name] [-d dir]
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
Inside the REPL: `install <name> [--version V]`.
|
|
1095
|
+
|
|
1096
|
+
Package layout:
|
|
1097
|
+
|
|
1098
|
+
```
|
|
1099
|
+
~/.chemql/packages/<name>/<version>/
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
---
|
|
1103
|
+
|
|
1104
|
+
## License and attribution
|
|
1105
|
+
|
|
1106
|
+
[MIT License](https://github.com/rakibulofficial1017/ChemQL/blob/main/LICENSE)
|
|
1107
|
+
|
|
1108
|
+
Created by [Mohammad Rakibul Islam](https://github.com/rakibulofficial1017).
|
|
1109
|
+
Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017/ChemQL).
|
|
1110
|
+
|
|
1111
|
+
---
|
|
1112
|
+
|
|
1113
|
+
For the command reference that matches your installed build, type `help` inside ChemQL.
|