Skip to content

Instantly share code, notes, and snippets.

var headAndTail: (head: Element, tail: SubSequence)? {
var iter = makeIterator()
guard let head = iter.next() else { return nil }
let tail = dropFirst(0)
return (head, tail)
}
@lancep
lancep / collection.md
Last active April 3, 2018 21:46
Collection additions

Collection additions

  • Proposal:
  • Authors: Lance Parker
  • Review Manager: TBD
  • Status: Awaiting Review

Introduction

Finding, replacing, removing, counting, and splitting one ordered collection on the contents of another is extremely useful (and would fill some holes in today's String API as well). We propose adding these and some other related methods to BidirectionalCollection and RangeReplaceableCollection as appropriate.

Two of these additions are currently being pitched here:

### Keybase proof
I hereby claim:
* I am lancep on github.
* I am lanceparker (https://keybase.io/lanceparker) on keybase.
* I have a public key whose fingerprint is 0EA6 4563 0EF4 9C08 C5E9 07CA DC40 B6C5 C15A 7C4D
To claim this, I am signing this object:
@lancep
lancep / gist:51f310ce2520a0372b25
Created November 2, 2014 03:29
Find the file with the most { } pairs in it
find . -type f -name "*.m" | while read f; do echo -n "$f "; cat "$f" | tr -dc '{}'; echo; done | awk '{ print length($2), $1 }' | sort -n