Skip to content

Instantly share code, notes, and snippets.

@hsleedevelop
Last active May 15, 2019 11:45
Show Gist options
  • Select an option

  • Save hsleedevelop/350bcacf16bce7459d1dfb56638aebeb to your computer and use it in GitHub Desktop.

Select an option

Save hsleedevelop/350bcacf16bce7459d1dfb56638aebeb to your computer and use it in GitHub Desktop.
likeReshapes
let half = round(list.count.d / 2.d).i
let reshapes = (list[0...half].map { $0 }, list[half..<list.count].map { $0 })
self.list = (0..<half).flatMap { i -> [HomeDataType] in [reshapes.0[i]] + (i < reshapes.1.count ? [reshapes.1[i]] : []) }
@hsleedevelop
Copy link
Author

ex) [1, 2, 3, 4, 5, 6, 7, 8] -> [1, 5, 2, 6, 3, 7, 4, 8]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment