eval-syntax
- Dominant language
- JavaScript
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Expose an eval syntax. Similar to [`new Function()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/Function) (used by AlpineJS) or [`eval()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) but doesn't expose global variable and Web API. Also no new variable creation a.k.a `let` or `const`. No declaration, no statement, no loop. It just an expression. However, it may have ternary operation and range/slice bound.
Some ideas:
- Typyst math syntax
- [CortexJS Compute Engine](https://cortexjs.io/compute-engine/) and MathJSON
- [Nerdamer](https://github.com/together-science/nerdamer-prime)
- [MathJS](https://mathjs.org/docs/index.html)
- small [math-expression-evaluator](https://github.com/bugwheels94/math-expression-evaluator)
---
Operator that exclusive for string, list/array, and vector/matrix are denoted in `[ops]`. There's some ops-syntax borrowed from other lang.
### concat (inspired by Lua)
```html
…
```
same as
```js
span.textContent = sepByComma(
scale3d.concat([0, 0, 0])
)
```
### scalar add on vector
```html
…
```
same as
```js
span.textContent = sepByComma(
scale3d.map(it => it + 5)
)
```
### addition between vector
```html
…
```
**roughly** same as
```js
span.textContent = sepByComma(
Array.from(
{ length: Math.max(scale3d.length, pos2d.length) },
(_, i) => (scale3d[i] ?? null) + (pos2d[i] ?? null),
)
)
```
---
Note that to enter eval-syntax, the expression should be wrapped in `` `() ``
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.