This is a generalization of the existing (and oddly specific) 
String.chunk/2 function that takes a string and a single-argument predicate 
function, returning a list of strings.

e.g.
String.chunk_by(" foo   bar ", &(&1 =~ ~r/\w/))
# => [" ", "foo", "   ", "bar", " "]

The above example makes problems such as "wrap text at <line limit> 
preserving whitespace" or "truncate string to x number of words while 
preserving whitespace" simpler.

The actual change would be pretty small and consist of renaming `chunk` to 
`chunk_by`, removing a line, and re-defining `chunk` as a slightly 
specialized call to `chunk_by`

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/01208415-3167-4794-9487-566ecebb451en%40googlegroups.com.

Reply via email to