Skip to content

Instantly share code, notes, and snippets.

View kas-elvirov's full-sized avatar
🇷🇺

Kas Elvirov kas-elvirov

🇷🇺
View GitHub Profile
@kas-elvirov
kas-elvirov / license-badges.md
Created March 10, 2017 06:03 — forked from lukas-h/license-badges.md
License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file. Easily copy and paste the code under the badges into your Markdown files.

Notes

  • Badges are made with Shields.io.
  • This badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.

Want to add a License?

Comment this gist or write me an E-Mail (lukas@himsel.me)

@kas-elvirov
kas-elvirov / nemathodeApiWithLove.js
Last active May 23, 2021 16:13
Nemathode Api - With love
import Nemathode from 'nemathode';
import { config } from './config';
const nemathode = Nemathode({
...config,
});
// doing same thing as `evaluate` but with love (don't forget being polite even with code)
const res = nemathode.evaluatePlease([...]);
@kas-elvirov
kas-elvirov / nemathodeApiStandart.js
Last active May 23, 2021 16:12
Nemathode Api-Standart
import Nemathode from 'nemathode';
import { config } from './config';
const nemathode = Nemathode({
...config,
});
// method for expression evaluation
const res = nemathode.evaluate([...]);
@kas-elvirov
kas-elvirov / nemathodePureJSConfigurationExample.js
Last active May 23, 2021 13:34
Nemathode PureJS configuration example
const config = {
mathConstants: {
'E': Math.E,
'LN2': Math.LN2,
'LN10': Math.LN10,
'LOG10E': Math.LOG10E,
'LOG2E': Math.LOG2E,
'PI': Math.PI,
'SQRT1_2': Math.SQRT1_2,
'SQRT2': Math.SQRT2,
@kas-elvirov
kas-elvirov / nemathodeWithFunctions.js
Last active May 23, 2021 11:35
Nemathode with functions
const customFunction = nemathode.evaluate([1, '+', ['abs', 1, 2, 3]]); //a rguments are not evaluated (future)
const singleFunction = nemathode.evaluate([['abs', 1, 2, 3]]; // single function syntax (it's not convinient, but for now it's only way)
const boolResult = nemathode.evaluate([['areEqual', 1, 2, 3]]); // returns boolean
// etc
@kas-elvirov
kas-elvirov / nemathodePseudocode.txt
Last active May 23, 2021 11:09
Nemathode - Pseudocode
[0, '+', 1] === (0 + 1)
[0, '+', 1, '*', [2, '/', 3, '-', 4]] === (0 + 1б * (2 / 3 - 4))
@kas-elvirov
kas-elvirov / nemathodeOperatorConfigurationExample.md
Created May 22, 2021 17:46
Nemathode operator configuration example
...
    '+': {
        precedence: 1,
        implementation: (l: number, r: number): number => {
            return l + r;
        },
    }
...
@kas-elvirov
kas-elvirov / nemathodeToOutputTypeConfigurationExample.ts
Created May 22, 2021 17:42
Nemathode toOutputType configuration example
const toOutputValue = (val: unknown): number | boolean => {
if (val instanceof Decimal) {
return val.toNumber();
}
return val;
};
@kas-elvirov
kas-elvirov / nemathodeToInputTypeConfigurationExample.ts
Created May 22, 2021 17:40
Nemathode toInputType configuration example
const toInputType = (val: unknown): Decimal | unknown => {
if (typeof val === 'number') {
const input = new Decimal(val);
return input;
}
return val;
};
@kas-elvirov
kas-elvirov / nemathodeWithNestedExpressions.js
Created May 22, 2021 17:30
Nemathode with nested expressions
const resOfNestedExp = nemathode.evaluate([1, '+', 'PI', '*', ['abs', 1, 2, 3], '-', [1, '+', [1, '/', 25]]]);