UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

42 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ValueSetBottom = exports.ValueSetTop = exports.ValueEmptySet = void 0; exports.setFrom = setFrom; exports.isSet = isSet; const general_1 = require("../general"); const r_value_1 = require("../r-value"); function flattenSetElements(s) { return (0, general_1.bottomTopGuard)(s) ?? s.flatMap(e => { return e.type === 'set' ? flattenSetElements(e.elements) : e; }); } /** * Creates a value set from the given elements. * @see {@link isSet} - to check whether a value is a set */ function setFrom(...elements) { const vals = elements.flatMap(e => { return e.type === 'set' ? flattenSetElements(e.elements) : e; }); return (0, general_1.bottomTopGuard)(...vals) ?? { type: 'set', elements: vals }; } /** * Checks, whether the given value is a set. * @see {@link setFrom} - to create sets */ function isSet(element) { return element.type === 'set'; } exports.ValueEmptySet = setFrom(); exports.ValueSetTop = { type: 'set', elements: r_value_1.Top }; exports.ValueSetBottom = { type: 'set', elements: r_value_1.Top }; //# sourceMappingURL=set-constants.js.map