Re: Substring look-up

zxq9 <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <[email protected]>
On 2021/04/07 19:37, Olivier Boudeville wrote:
> Hello Dan,
> 
> Thanks for your answer; indeed rewriting most uses of string:rstr/2 in 
> terms of string:split/3 and others should be possible, and each string 
> traversal must be expensive now.

Sometimes going the neanderthal route is a simplification:

1. unicode:characters_to_list/1
2. write a custom function to iterate as a list the original way

The more complex the original representation and more interesting the 
sort of work you want done the more this approach tends to save me in 
both cognitive and processing overhead. My case may be highly optimized 
for this, though, as I usually deal with English, German and Japanese 
and rarely any other text input languages -- some input forms for other 
languages can get pretty interesting and probably don't map as well to 
the concept of "characters" after conversion.

-Craig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.