Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence() #70

Closed
elliotchance opened this issue Apr 30, 2019 · 2 comments · Fixed by #108
Closed

Sequence() #70

elliotchance opened this issue Apr 30, 2019 · 2 comments · Fixed by #108
Labels
good first issue Good for newcomers

Comments

@elliotchance
Copy link
Owner

elliotchance commented Apr 30, 2019

Generates a sequence of numbers between min and max inclusive:

pie.Ints{}.Sequence(5, 8)
// pie.Ints{5, 6, 7, 8}

There could also be an optional third argument for the step size:

pie.Ints{}.Sequence(5, 8, 2)
// pie.Ints{5, 7}
@elliotchance elliotchance added the good first issue Good for newcomers label May 1, 2019
@zhiburt
Copy link
Contributor

zhiburt commented May 6, 2019

Hey @elliotchance, are you sure in sequence of numbers between min and max inclusive?
It may be better not inclusive.

pie.Ints{}.Sequence(5, 8)
// pie.Ints{5, 6, 7}

I consider that's better thing, in most languages this one works in such way.

This was referenced May 6, 2019
@elliotchance
Copy link
Owner Author

Yes, you’re right. The upper bound should not be inclusive.

elliotchance pushed a commit that referenced this issue May 8, 2019
Sequence generates all numbers in range or returns nil if params invalid

There are 3 variations to generate:

    1. [0, n).
    2. [min, max).
    3. [min, max) with step.

If len(params) == 1 considered that will be returned slice between 0 and n,  where n is the first param, [0, n).
If len(params) == 2 considered that will be returned slice between min and max, where min is the first param, max is the second, [min, max).
If len(params) > 2 considered that will be returned slice between min and max with step, where min is the first param, max is the second, step is the third one, [min, max) with step, others params will be ignored.

Fixes #70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants