@compute.ts/number
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Presentation

The engine is based on incremental computation algorithms. When a calculation is submitted to the engine, all the computed values are memorized. So, if you change some variable and query an evaluation, the engine is able to compute the result very fast because it recomputes only what has changed.

compute.ts

Libraries

The project provides several libraries that each comes with dozens of operators. Please note the cross-compatibility of the libraries.

Imports

Typescript

import {/* required operators */} from '@compute.ts/number';

Javascript

const {/* required operators */} = require('@compute.ts/number');

Operators

number

number(value) ➜ xnumber
number() ➜ xnumber

The number operator allows to create a number expression which evals to the given value. If no value is provided the expression is a variable and can be affected

import {number} from "@compute.ts/number";

const x = number(5) | number();  

x.affect(8);

randomNumber

randomNumber(xnumber, ynumber) ➜ znumber

The randomNumber operator allows to create a number expression which evals to a random number between the given boundaries

import {number, randomNumber} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = randomNumber(x, y);

const value = z.eval();

zero

zero ➜ xnumber

The zero operator allows to create a number expression which evals to 0

import {zero} from "@compute.ts/number";

const x = zero;  

x.affect(2);

one

one ➜ xnumber

The one operator allows to create a number expression which evals to 1

import {one} from "@compute.ts/number";

const x = one;  

x.affect(2);

opposite

opposite(xnumber) ➜ ynumber
xnumber.opposite() ➜ ynumber

The opposite operator allows to create a number expression which evals to the opposite of the given expression

import {number, opposite} from "@compute.ts/number";

const x = number();  
const y = opposite(x) | x.opposite() ;

const value = y.eval();

plus

plus(x0number, x1number, ..., xnnumber) ➜ ynumber
xnumber.plus(x0number, x1number, ..., xnnumber) ➜ ynumber

The plus operator allows to create a number expression which evals to the sum of all the given expressions

import {number, plus} from "@compute.ts/number";

const x0 = number();  
const x1 = number();  
// ....  
const xn = number();

const y = plus(x0, x1, ..., xn) | x0.plus(x1, ..., xn);

const value = y.eval();

multiply

multiply(x0number, x1number, ..., xnnumber) ➜ ynumber
xnumber.multiply(x0number, x1number, ..., xnnumber) ➜ ynumber

The multiply operator allows to create a number expression which evals to the multiplication of all the given expressions

import {number, multiply} from "@compute.ts/number";

const x0 = number();  
const x1 = number();  
// ....  
const xn = number();

const y = multiply(x0, x1, ..., xn) | x0.multiply(x1, ..., xn);

const value = y.eval();

minus

minus(x0number, x1number, ..., xnnumber) ➜ ynumber
xnumber.minus(x0number, x1number, ..., xnnumber) ➜ ynumber

The minus operator allows to create a number expression which evals to the first given element minus all the elements which comes after

import {number, minus} from "@compute.ts/number";

const x0 = number();  
const x1 = number();  
// ....  
const xn = number();

const y = minus(x0, x1, ..., xn) | x0.minus(x1, ..., xn);

const value = y.eval();

divide

divide(xnumber, ynumber) ➜ znumber
xnumber.divide(ynumber) ➜ znumber

The divide operator allows to create a number expression which evals to the division of x by y

import {number} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = divide(x, y) | x.divide(y);

const value = z.eval();

modulo

modulo(xnumber, ynumber) ➜ znumber
xnumber.modulo(ynumber) ➜ znumber

The modulo operator allows to create a number expression which evals to the rest of the division of x by y

import {number, modulo} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = modulo(x, y) | x.modulo(y);

const value = z.eval();

lessThan

lessThan(xnumber, ynumber) ➜ zboolean
xnumber.lessThan(ynumber) ➜ zboolean

The lessThan operator allows to create a boolean expression which evals to true if x is less than y

import {number, lessThan} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = lessThan(x, y) | x.lessThan(y);

const value = z.eval();

lessOrEqualThan

lessOrEqualThan(xnumber, ynumber) ➜ zboolean
xnumber.lessOrEqualThan(ynumber) ➜ zboolean

The lessOrEqualThan operator allows to create a boolean expression which evals to true if x is less or equal than y

import {number, lessOrEqualThan} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = lessOrEqualThan(x, y) | x.lessOrEqualThan(y);

const value = z.eval();

greaterThan

greaterThan(xnumber, ynumber) ➜ zboolean
xnumber.greaterThan(ynumber) ➜ zboolean

The greaterOrEqualThan operator allows to create a boolean expression which evals to true if x is greater y

import {number, greaterThan} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = greaterThan(x, y) | x.greaterThan(y);

const value = z.eval();

greaterOrEqualThan

greaterOrEqualThan(xnumber, ynumber) ➜ zboolean
xnumber.greaterOrEqualThan(ynumber) ➜ zboolean

The greaterOrEqualThan operator allows to create a boolean expression which evals to true if x is greater or equal y

import {number, greaterOrEqualThan} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = greaterOrEqualThan(x, y) | x.greaterOrEqualThan(y);

const value = z.eval();

equal

equal(xnumber, ynumber) ➜ zboolean
xnumber.equal(ynumber) ➜ zboolean

The equals operator allows to create a boolean expression which evals to true if x and y are the same equals

import {number, equal} from "@compute.ts/number";

const x = number();  
const y = number();  
const z = equal(x, y) | x.equal(y);

const value = z.eval();

isZero

isZero(xnumber) ➜ yboolean
xnumber.isZero() ➜ yboolean

The isZero operator allows to create a boolean expression which evals to true if x is zero

import {number, isZero} from "@compute.ts/number";

const x = number();  
const y = isZero(x) | x.isZero();

const value = y.eval();

isPositive

isPositive(xnumber) ➜ yboolean
xnumber.isPositive() ➜ yboolean

The isPositive operator allows to create a boolean expression which evals to true if x is positive

import {number, isPositive} from "@compute.ts/number";

const x = number();  
const y = isPositive(x) | x.isPositive();

const value = y.eval();

isNegative

isNegative(xnumber) ➜ yboolean
xnumber.isNegative() ➜ yboolean

The isNegative operator allows to create a boolean expression which evals to true if x is negative

import {number, isNegative} from "@compute.ts/number";

const x = number();  
const y = isNegative(x) | x.isNegative();

const value = y.eval();

isEven

isEven(xnumber) ➜ yboolean
xnumber.isEven() ➜ yboolean

The isEven operator allows to create a boolean expression which evals to true if x is even

import {number, isEven} from "@compute.ts/number";

const x = number();  
const y = isEven(x) | x.isEven();

const value = y.eval();

isOdd

isOdd(xnumber) ➜ yboolean
xnumber.isOdd() ➜ yboolean

The isOdd operator allows to create a boolean expression which evals to true if x is odd

import {number, isOdd} from "@compute.ts/number";

const x = number();  
const y = isOdd(x) | x.isOdd();

const value = y.eval();

isPrime

isPrime(xnumber) ➜ yboolean
xnumber.isPrime() ➜ yboolean

The isPrime operator allows to create a boolean expression which evals to true if x is prime

import {number, isPrime} from "@compute.ts/number";

const x = number();  
const y = isPrime(x) | x.isPrime();

const value = y.eval();

About the author

I am a software developer with 4 years of project specializing in the development of web solutions. Digital Nomad, I work while traveling. After 3 years into the french industry, I've started to work as a freelance software architect or fullstack developer.

Based on state-of-the-art web technologies, I offer you to architect & develop the best version of your project. My experience in the web app development assure you to build a nice looking, performant and stable product.

Minimalist, I like to travel, to meet people, learn new things and handmade stuff. Scuba & sky diving licenced. I like also hamburgers, Kinder chocolate and crepes. Karate black belt.

https://berthellemy.com/


Package Sidebar

Install

npm i @compute.ts/number

Weekly Downloads

1

Version

2.0.3

License

MIT

Unpacked Size

37.5 kB

Total Files

12

Last publish

Collaborators

  • mberthellemy