Skip to content

Implement .has / .includes method #25

@parzhitsky

Description

@parzhitsky

Example:

xrange(10).has(7); // true
xrange(2, -3).has(5); // false
const range = xrange(0, 10, 2);

range.has(6); // true
range.has(7); // false
range.has(8); // true

Functional implementation is just too unpredictable to have this functionality:

xrange(0, () => Math.random() > 0.5, () => 0).has(0);
// Error: cannot probe items of a non-deterministic range
// (even if `0` is clearly there, such predicate might make the whole range empty)
xrange(0, () => true, ([ last ]) => last === 6 ? CONSTANT : last + 1).has(7);
// Error: cannot probe items of a non-deterministic range
// (whether this range has 7 depends on the value of `CONSTANT`)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Change: minor[Issue / PR] describes a non-breaking change, such as adding a new functionalityDomain: main[Issue / PR] describes change in the functionality, its optimizationPending: blocked[Issue / PR] cannot be addressed until another issue is resolvedPriority: low[Issue / PR] could be addressed at any convenient timeType: improvement[Issue / PR] addresses lack of a functionality or an open possibility of enhancementgood first issue[Issue] can be addressed by a first-time contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions