Skip to content

Allow custom sequence start #48

@parzhitsky

Description

@parzhitsky

When generating numeric sequences, allow starting them with more than one number:

xrange([1, 1], () => true, ([ last, prelast ]) => last + prelast);
// 1, 1, 2, 3, 5, 8, 13, 21, 34, …

xrange([0, 1, 2, 3, 4], (next) => next < 3, ([ last ]) => last + 1);
// 0, 1, 2
// custom sequence start goes through ("obeys") the predicate

xrange([], (next) => next < 100, ([ last ]) => last + 1);
// (no iterations)
// since sequence start is not defined, the first sequence member is `NaN`, and `NaN < 100` is `false`

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: medium[Issue / PR] should be addressed without delayType: 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