You can also pattern match on the range first and last:

first .. last = range



*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Tue, Dec 20, 2016 at 11:00 PM, 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]> 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/msgid/elixir-lang-core/CAGnRm4K0
>>>>> Rk2uMJVTCNQi9t7nHD%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/ms
>> gid/elixir-lang-core/CAN3B1jd8XHGCJo%3D5ChJo9OyeLRA5D-iMdW3F
>> mvGOz4o_%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/CAK%3D%2B-TuLuo6KizgHFTLpCJrheYkHc%
> 3DJ%2BowquQhz1SetPHkWj4w%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CAK%3D%2B-TuLuo6KizgHFTLpCJrheYkHc%3DJ%2BowquQhz1SetPHkWj4w%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/CAGnRm4KnB%2BGDQdHo9JvmsBC6v_nn7hN%3DZz7P92ikm9knu4VQ4w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to