0.0.16 • Published 9 years ago

setcom v0.0.16

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

setcom

General Set Declaration DSL.

Set operation DSL.

install

npm i setcom --save

set example

  • eg1: B = {x | x ∈ A, x > 0}
let setcom = require('setcom');
let elemOf = setcom.elemOf;
let all = setcom.all;
let predicate = setcom.predicate;

let A = [-1, 2, 3, -4];
let x = elemOf(A);
predicate(x, (x) => x > 0);
let B = all(x);
console.log(B); // [2, 3]
  • eg2: C = {(x, y) | x ∈ A, y ∈ B, x + y < 20}
let setcom = require('setcom');
let elemOf = setcom.elemOf;
let all = setcom.all;
let predicate = setcom.predicate;

let A = [6, 10, 20];
let B = [12, 2];
let x = elemOf(A);
let y = elemOf(B);
predicate(x, y, (x, y) => x + y < 20);
let C = all(x, y);
console.log(C); // [[6, 12], [6, 2], [10, 2]]
  • eg3: B = {y | y = x.a, x ∈ A}
let setcom = require('setcom');
let elemOf = setcom.elemOf;
let all = setcom.all;
let predicate = setcom.predicate;
let assign = setcom.assign;

let A = [{a: 3, b: 2}, {a: 4, b: 5}];
let x = elemOf(A);
let y = assign(x, (x) => x.a);
let B = all(y);
console.log(B); // [3, 4]

logic example

  • eg: any x in set A, x > 0
let setcom = require('setcom');
let elemOf = setcom.elemOf;
let logic = setcom.logic;
let any = setcom.any;

let A = [1, 2, 3];

logic(any(elemOf(A)), (x) => x > 0); // true
  • eg: for any x in A, exist y in B, x + y > 20
let setcom = require('setcom');
let elemOf = setcom.elemOf;
let logic = setcom.logic;
let any = setcom.any;
let exist = setcom.exist;

let A = [1, 2, 3];
let B = [30, 20];

logic(any(elemOf(A)), exist(elemOf(B)), (x, y) => x + y > 20); // true
0.0.16

9 years ago

0.0.15

9 years ago

0.0.14

9 years ago

0.0.13

9 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago