<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>You can do this trivially with drop. But enumerated from has one nice property:</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">myArray.enumerated().dropFirst(6) // counts from 6</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">myArray.dropFirst(6).enumerated() // counts from 0</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Those two lines do very different things even though they look similar</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">myArray.enumerated(from: 6)</div><div id="AppleMailSignature">Is unambiguous&nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">But I don't think it is worth adding to the sequence protocol if the argument is that it's unambiguous.&nbsp;</div><div id="AppleMailSignature"><br>Andre Videla&nbsp;</div><div><br>On 4 May 2017, at 14:39, Pavol Vaskovic via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>Hello!<div><br></div><div>Here's a pitch to pick a small nit from the Sequence protocol:</div><div><br></div><div><a href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md">https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md</a><br></div><div><br></div><div>Best regards</div><div>Pavol Vaskovic</div><div><br></div><div><div style="box-sizing:border-box;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;background-color:rgb(255,255,255)"><div itemscope="" itemtype="http://schema.org/SoftwareSourceCode" style="box-sizing:border-box"><div id="js-repo-pjax-container" style="box-sizing:border-box"><div class="container new-discussion-timeline experiment-repo-nav" style="box-sizing:border-box;width:980px;margin-right:auto;margin-left:auto"><div class="repository-content" style="box-sizing:border-box"><div class="file" style="box-sizing:border-box;margin-top:16px;margin-bottom:16px;border:1px solid rgb(221,221,221);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"><div id="readme" class="readme blob instapaper_body" style="box-sizing:border-box"><h1 style="box-sizing:border-box;font-size:2em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239);margin-top:0px!important">Enumerate from offset</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px"><li style="box-sizing:border-box"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Proposal:&nbsp;<a href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">SE-NNNN</a></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Authors:&nbsp;<a href="https://github.com/palimondo" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Pavol Vaskovic</a>,&nbsp;<a href="https://github.com/swiftdev" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Author 2</a></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Review Manager: TBD</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Status:&nbsp;<span style="box-sizing:border-box;font-weight:600">Pitch</span></p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">Bugs:&nbsp;<a href="https://bugs.swift.org/browse/SR-4746" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">SR-4746</a></p></li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-introduction" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">Let user specify the staring index for&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">enumerated</code>&nbsp;method on&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence</code>s.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">Swift-evolution thread:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">Discussion thread topic for that proposal</a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-motivation" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">The&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">enumerated()</code>&nbsp;method defined in an extension on protocol Sequence always counts from&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">0</code>. When you need the numbers to be counting up from different index, you have to post process the resulting tuple in an inconvenient way.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-proposed-solution" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#proposed-solution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Proposed solution</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">We could provide an option to count elements from a user specified offset:</p><div class="highlight highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal">[<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">6</span>, <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">7</span>, <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">8</span>].<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">enumerated</span>(<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">from</span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">6</span>)
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">//</span> [(offset: 6, element: 6), (offset: 7, element: 7), (offset: 8, element: 8)]</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">If implemented with default parameter, this does not change the usage for existing code, being source compatible with Swift 3.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-detailed-design" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#detailed-design" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Detailed design</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">The proposed solution is to propagate the starting value to the internal counter on&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">EnumeratedIterator</code>&nbsp;and set the default starting value to&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">0</code>.</p><div class="highlight highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal"><span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">EnumeratedIterator</span>&lt;
    <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span> : <span class="pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">IteratorProtocol</span></span>
<span class="pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"></span>&gt; : <span class="pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">IteratorProtocol</span></span>, <span class="pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Sequence</span> </span>{
    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">internal</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> _base<span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span>
    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">internal</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> _count<span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>
    
    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> Construct from a `Base` iterator.</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">internal</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">_base</span></span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span>, <span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">_offset</span></span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>) {
        <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">_base</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> _base
        <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">_count</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> _offset
    }
    
    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> The type of element returned by `next()`.</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">typealias</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Element</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> (offset: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>, element: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span>.<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Element</span>)
    
    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> Advances to the next element and returns it, or `nil` if no next element</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> exists.</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)">///</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> Once `nil` has been returned, all subsequent calls return `nil`.</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">mutating</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">next</span>() <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Element</span><span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> {
        <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> b <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> _base.<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">next</span>() <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">nil</span> }
        <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> result <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> (<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">offset</span>: _count, <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">element</span>: b)
        _count <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">+=</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">1</span>
        <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> result
    }
}

<span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">struct</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">EnumeratedSequence</span>&lt;<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span> : <span class="pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Sequence</span></span>&gt; : <span class="pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Sequence</span> </span>{
    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">internal</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> _base<span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span>
    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">internal</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> _offset<span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>
    
    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> Construct from a `Base` sequence.</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">internal</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">_base</span></span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span>, <span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">_offset</span></span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span>) {
        <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">_base</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> _base
        <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">_offset</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> _offset
    }
    
    <span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="pl-c" style="box-sizing:border-box">///</span> Returns an iterator over the elements of this sequence.</span>
<span class="pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">makeIterator</span>() <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> _EnumeratedIterator&lt;<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Base</span>.<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Iterator</span>&gt; {
        <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">EnumeratedIterator</span>(<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">_base</span>: _base.<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">makeIterator</span>(), <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">_offset</span>: _offset)
    }
}

<span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">extension</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Sequence</span></span> {
    <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">enumerated</span>(<span class="pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">from</span></span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Int</span> <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">0</span>) <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> _numeratedSequence&lt;<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Self</span>&gt; {
        <span class="pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">EnumeratedSequence</span>(<span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">_base</span>: <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>, <span class="pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">_offset</span>: from)
    }
}</pre></div><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-source-compatibility" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#source-compatibility" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Source compatibility</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">Proposed change is source compatible with Swift 3.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-effect-on-abi-stability-and-resilience" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#effect-on-abi-stability-and-resilience" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Effect on ABI stability and resilience</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">This change does affect the ABI and should be implemented before we freeze it.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(234,236,239)"><a id="user-content-alternatives-considered" class="anchor" href="https://github.com/palimondo/swift-evolution/blob/sequence-cleanup/proposals/NNNN-enumerate-from.md#alternatives-considered" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none;float:left;padding-right:4px;line-height:1"></a>Alternatives considered</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">Currently proposed workaround for the lack of flexibility in&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">enumerated()</code>&nbsp;is to use&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">zip</code>&nbsp;with the collection and half-open range. From&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0172-one-sided-ranges.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration:none">SR-0172 One-sided Ranges</a>:</p><blockquote style="box-sizing:border-box;margin:0px 0px 16px;padding:0px 1em;color:rgb(106,115,125);border-left-width:0.25em;border-left-style:solid;border-left-color:rgb(223,226,229)"><p style="box-sizing:border-box;margin-top:0px;margin-bottom:0px">Additionally, when the index is a countable type,&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">i...</code>&nbsp;should form a&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence</code>&nbsp;that counts up from&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">i</code>&nbsp;indefinitely. This is useful in forming variants of&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence.enumerated()</code>&nbsp;when you either want them non-zero-based i.e.<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">zip(1..., greeting)</code>, or want to flip the order i.e.&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">zip(greeting, 0...)</code>.</p></blockquote><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px">Drawback of this approach is that you need to use free function&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">zip</code>, forcing a break in the chain of sequence operations, as there is currently no&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">zipped</code>&nbsp;method on&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Sequence</code>.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:0px!important">If this is the preffered approach, we should consider removing the&nbsp;<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.0470588);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">enumerated()</code>&nbsp;method altogether, because the limited usefullness in its current state hardly justifies the space on API surface it occupies.</p></div></div></div></div></div></div></div><div class="container site-footer-container" style="box-sizing:border-box;width:980px;margin-right:auto;margin-left:auto;color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:14px;background-color:rgb(255,255,255)"><div class="site-footer" style="box-sizing:border-box;padding-top:40px;padding-bottom:40px;margin-top:40px;font-size:12px;line-height:1.5;color:rgb(88,96,105);border-top-width:1px;border-top-style:solid;border-top-color:rgb(234,236,239)"></div></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>