I proposed this in the past. Code is still valid today as very little changes 
have been done to the
Range module.

Date: Mon, 15 Feb 2016 12:23:39 +0700
Reply-To: [email protected]
Sender: [email protected]

I have created a set of functions for the range module.
Initially, I based my work in functions written by "jdl"
https://github.com/mykewould/crutches/blob/ddf5535d66601f9630bee1807ef38cb57f52b9b4/lib/crutches/range.ex

You can have a look at the module and tests:
https://github.com/eksperimental/elixir/blob/range/lib/elixir/lib/range.ex
https://github.com/eksperimental/elixir/blob/range/lib/elixir/test/elixir/range_test.exs

New functions are: congruent?/2, disjoint?2, contiguous?/2,
intersection/2, member?/2, overlaps?/2, reverse/1, size/1, sort/2,
subset?/2, to_list/2, union/2

Some functions have been taken from MapSet, and other apply exclusively
to Range.

Please let me know what you think of this.

And if there is an interest in adding this Elixir, I will have to
contact the author of the initial functions for release permission.

Cheers



On Tue, 20 Dec 2016 16:00:33 -0600
Paul Schoenfelder <[email protected]> wrote:

> Drew, you can use r.first and r.last, where r is the binding for the range
> in question. Ranges are a struct with first and last fields.
> 
> On Tue, Dec 20, 2016 at 3:59 PM, Drew Olson <[email protected]> wrote:
> 
> > I was working on the same problem today and would have also found it
> > useful to have something like `Range.first/1` and `Range.last/1` for
> > accessing the inclusive bounds (these are probably terrible names).
> >
> > On Tue, Dec 20, 2016 at 3:55 PM, José Valim <[email protected].
> > br> wrote:
> >
> >> If so, it may be a good addition but a better name is required, such as
> >> overlaps? or subset?.
> >>
> >>
> >>
> >> *José Valim*
> >> www.plataformatec.com.br
> >> Skype: jv.ptec
> >> Founder and Director of R&D
> >>
> >> On Tue, Dec 20, 2016 at 10:53 PM, Paul Schoenfelder <
> >> [email protected]> wrote:
> >>
> >>> I think he is looking for a Range function which answers whether a range
> >>> is a subset of another range, e.g. 1..10 contains 2..4 == true.
> >>>
> >>> On Tue, Dec 20, 2016 at 3:47 PM, José Valim <
> >>> [email protected]> wrote:
> >>>
> >>>> Is there any reason to use Range.contains? given you can already do "x
> >>>> in range" or "Enum.member?(range, x)" (they are equivalent).
> >>>>
> >>>>
> >>>>
> >>>> *José Valim*
> >>>> www.plataformatec.com.br
> >>>> Skype: jv.ptec
> >>>> Founder and Director of R&D
> >>>>
> >>>> On Tue, Dec 20, 2016 at 10:43 PM, Patrick Davey <
> >>>> [email protected]> wrote:
> >>>>
> >>>>> I wanted to check if a range contained another range today while I was
> >>>>> doing one of the www.adventofcode.com puzzles.
> >>>>>
> >>>>> I discussed it on the forum and I have done a search and it doesn't
> >>>>> look like it has been proposed before, apologies if I have missed 
> >>>>> something.
> >>>>>
> >>>>> Anyway, just an idea, I'm happy to have a go at implementing it if
> >>>>> it's something which merits approval. I understand if it's too simple a
> >>>>> thing to be bothered implementing.
> >>>>>
> >>>>> Thanks to the team for Elixir - I'm thoroughly enjoying getting more
> >>>>> comfortable with it through the advent of code puzzles :)
> >>>>>
> >>>>> --
> >>>>> You received this message because you are subscribed to the Google
> >>>>> Groups "elixir-lang-core" group.
> >>>>> To unsubscribe from this group and stop receiving emails from it, send
> >>>>> an email to [email protected].
> >>>>> To view this discussion on the web visit
> >>>>> https://groups.google.com/d/msgid/elixir-lang-core/62203f2a-
> >>>>> fe01-46e8-a373-16f40b860578%40googlegroups.com
> >>>>> <https://groups.google.com/d/msgid/elixir-lang-core/62203f2a-fe01-46e8-a373-16f40b860578%40googlegroups.com?utm_medium=email&utm_source=footer>
> >>>>> .
> >>>>> For more options, visit https://groups.google.com/d/optout.
> >>>>>
> >>>>
> >>>> --
> >>>> You received this message because you are subscribed to the Google
> >>>> Groups "elixir-lang-core" group.
> >>>> To unsubscribe from this group and stop receiving emails from it, send
> >>>> an email to [email protected].
> >>>> To view this discussion on the web visit https://groups.google.com/d/ms
> >>>> gid/elixir-lang-core/CAGnRm4K0Rk2uMJVTCNQi9t7nHD%3DHSsY4YRt_
> >>>> qEhTt6T4cot%3DPQ%40mail.gmail.com
> >>>> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4K0Rk2uMJVTCNQi9t7nHD%3DHSsY4YRt_qEhTt6T4cot%3DPQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> >>>> .
> >>>>
> >>>> For more options, visit https://groups.google.com/d/optout.
> >>>>
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> >>> Groups "elixir-lang-core" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> >>> an email to [email protected].
> >>> To view this discussion on the web visit https://groups.google.com/d/ms
> >>> gid/elixir-lang-core/CAK%3D%2B-TtyLV_yYN9yB6ESP85LOQg%3Dj9KZ
> >>> MqT1FC8YBAxSActRXw%40mail.gmail.com
> >>> <https://groups.google.com/d/msgid/elixir-lang-core/CAK%3D%2B-TtyLV_yYN9yB6ESP85LOQg%3Dj9KZMqT1FC8YBAxSActRXw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> >>> .
> >>> For more options, visit https://groups.google.com/d/optout.
> >>>
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "elixir-lang-core" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an
> >> email to [email protected].
> >> To view this discussion on the web visit https://groups.google.com/d/ms
> >> gid/elixir-lang-core/CAGnRm4LPbAK5UkMne9K-z4RJt3%2BfL3J3oQpc
> >> -B6nUR%2B-c04BZA%40mail.gmail.com
> >> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LPbAK5UkMne9K-z4RJt3%2BfL3J3oQpc-B6nUR%2B-c04BZA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> >> .
> >>
> >> For more options, visit https://groups.google.com/d/optout.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "elixir-lang-core" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To view this discussion on the web visit https://groups.google.com/d/
> > msgid/elixir-lang-core/CAN3B1jd8XHGCJo%3D5ChJo9OyeLRA5D-
> > iMdW3FmvGOz4o_%2B6f_%3DQ%40mail.gmail.com
> > <https://groups.google.com/d/msgid/elixir-lang-core/CAN3B1jd8XHGCJo%3D5ChJo9OyeLRA5D-iMdW3FmvGOz4o_%2B6f_%3DQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> > .
> >
> > For more options, visit https://groups.google.com/d/optout.
> >
> 

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/20161221050704.4a25a1de.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to