Skip to content

Instantly share code, notes, and snippets.

@itacirgabral
Created October 10, 2018 19:16
Show Gist options
  • Save itacirgabral/bb6cc408fd73b796a55c7bca624db682 to your computer and use it in GitHub Desktop.
Save itacirgabral/bb6cc408fd73b796a55c7bca624db682 to your computer and use it in GitHub Desktop.
var e = [
[["0a"],["0e"],["0i"],["0o"],["0u"]],
[["1a"],["1e"],["1i"],["1o"],["1u"]],
[["2a"],["2e"],["2i"],["2o"],["2u"]],
[["3a"],["3e"],["3i"],["3o"],["3u"]],
[["4a"],["4e"],["4i"],["4o"],["4u"]]
]
const yZip = e.reduce((a, b, i) => {
lst = a.slice(-1)[0]
if (i % 3) {
lst.forEach((e, i) => e.push(...b[i]))
} else {
a.push(b)
}
return a
}, [])
const xZip = e.map(
e => e.reduce((a, b, i) => {
lst = a.slice(-1)[0]
if (i % 3) {
lst.push(...b)
} else {
a.push(b)
}
return a
}, [])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment