Skip to content

Instantly share code, notes, and snippets.

@jeremycochoy
Created May 23, 2019 22:04
Show Gist options
  • Save jeremycochoy/c01984b5b065667402d6c80c7d73cf8e to your computer and use it in GitHub Desktop.
Save jeremycochoy/c01984b5b065667402d6c80c7d73cf8e to your computer and use it in GitHub Desktop.
init(from list: [T] = []) {
cursor = list.first
rightList = list
}
/// Convert to a swift array
func toList() -> [T] {
if let c = cursor {
return leftList + [c] + rightList.reversed()
} else {
return leftList + rightList.reversed()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment