Created
May 23, 2019 22:04
-
-
Save jeremycochoy/c01984b5b065667402d6c80c7d73cf8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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