Skip to content

Instantly share code, notes, and snippets.

View dennisvennink's full-sized avatar

Dennis Vennink dennisvennink

  • Rotterdam, The Netherlands
View GitHub Profile
let xs = [1, 2, 3, 4, 5]
for (element, index) in zip(xs, xs.indices) {
if index == xs.startIndex {
print("START")
}
print(element)
if index == xs.index(before: xs.endIndex) {
@dennisvennink
dennisvennink / headAndTail.swift
Last active January 17, 2021 09:49 — forked from ole/headAndTail.swift
Swift challenge: Sequence.headAndTail
extension Sequence {
var headAndTail: (head: Element, tail: SubSequence)? {
var head: Element?
let tail = drop {
if head == nil {
head = $0
return true
} else {