Created
July 14, 2019 16:47
-
-
Save max-potapov/82cb12b10993377f607b747bba910e8c to your computer and use it in GitHub Desktop.
Split single column list to two columns list
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
let list = raw.components(separatedBy: "\n") | |
let limit = list.count/2 | |
var formatted = "" | |
for (index, item) in list.enumerated() { | |
guard index < limit else { continue } | |
formatted.append(item) | |
formatted.append("\t") | |
formatted.append(list[index + limit]) | |
formatted.append("\n") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment