Skip to content

Instantly share code, notes, and snippets.

@Linell
Created April 28, 2015 18:00
Show Gist options
  • Select an option

  • Save Linell/2c274cc11a13a5acf3d5 to your computer and use it in GitHub Desktop.

Select an option

Save Linell/2c274cc11a13a5acf3d5 to your computer and use it in GitHub Desktop.
split a string up into given chunks
"Jose"
|> String.codepoints()
|> Enum.chunk(2)
|> Enum.map(&Enum.join(&1, ""))
# ["Jo", "se"]
@Linell

Linell commented Apr 28, 2015

Copy link
Copy Markdown
Author

Although, josevalim noted that you should probably use String.graphemes

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