Skip to content

Instantly share code, notes, and snippets.

@Linell
Created April 28, 2015 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Linell/2c274cc11a13a5acf3d5 to your computer and use it in GitHub Desktop.
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
Copy link
Author

Linell commented Apr 28, 2015

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