Code Monkey home page Code Monkey logo

Comments (6)

ericniebler avatar ericniebler commented on August 25, 2024

You're mistaken as to the purpose of as_range. It's for promoting Iterables to Ranges. Most of these exist already, but the have their own dedicated API. Why do you think the should all be unified?

from range-v3.

gnzlbg avatar gnzlbg commented on August 25, 2024

You're mistaken as to the purpose of as_range. It's for promoting Iterables to Ranges.

I'll have to re-read your posts again!

Why do you think the should all be unified?

I just find that a ranges::make(...) that does the right thing is more comfortable to use than particular functions like ranges::make_counting_range, ranges::make_iterator_range, ... although the implementation trouble might not be worth it since those above are the cases I have a use for but there might be more (way more maybe). I just build ranges from integers and pointers/iterators/raw arrays very often.

from range-v3.

ericniebler avatar ericniebler commented on August 25, 2024

I just find that a ranges::make(...) that does the right thing is more comfortable to use than particular functions like ranges::make_counting_range

If you mean a counted range that starts at some iterator and includes the next N elements, I call that ranges::view::counted. If you mean, all the integers starting from N, that's called ranges::view::iota.

ranges::make_iterator_range

I call that ranges::range.

There are so many different kinds of ranges, I just can't imaging an interface that unifies construction of all of them. And I don't see why that would be a better interface than saying what you mean explicitly, and having the programmer's intent visible in the code.

from range-v3.

gnzlbg avatar gnzlbg commented on August 25, 2024

The "problem" (and feature) of iota is that it is an "infinite" range. Most of the time I just want an integer range [a, b) so I would really appreciate having an utility function for creating them:

/// Integer range [a, b)
auto irng(Integral a, Integral b) { return view::take(view::iota(a), b); }
/// Integer range [a, b) with stride
auto irng(Integral a, Integral b, Integral stride) { return view::take(view::iota(a), b) | view::strided(stride); }
/// Predicated integer range starting at a
auto irng(Integral a, Predicate p) { return view::iota(a) | view::take_while(p); }

For the iterator versions I didn't knew about counted so the only case I'm missing is a "predicated" version of it. Any name suggestions for that one? If we had a way of creating an "infinite" range from a single iterator (the same way iota does for integers) one could use that with take_while to implement it.

from range-v3.

ericniebler avatar ericniebler commented on August 25, 2024

Agreed about iota. I've also never loved the name, despite the historical precedent. This needs a rethink.

from range-v3.

ericniebler avatar ericniebler commented on August 25, 2024

Opened a separate ticket for just the iota issue. Closing this one.

from range-v3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.