[erlang-questions] Strings as Lists

Kevin Scaldeferri kevin@REDACTED
Wed Feb 13 00:41:24 CET 2008

On Feb 12, 2008, at 2:13 PM, Robert Virding wrote:

> I think it all boils down to what you are going to *do* with these  
> strings. If you are just going to store them somewhere for later  
> then converting them to a binary definitely save space. If, however,  
> you are going to *work* with them then having them as lists is  
> definitely much better. It is so much easier than having fixed  
> sequence of octets. Also most, if not all declarative languages  
> functional and logic, have very optimised list handling because  
> lists are so practical to work with.

Hold on... lists aren't really a particular convenient or efficient  
data structure for working with strings.  First off, I append to  
strings a lot more than I prepend to them.  Yeah, I could work with  
reversed strings, but that's a hack to deal with using the wrong data  
type.  Plus, I probably prefix match more often than suffix matching  
(although this is less lopsided than append vs. prepend).  Of course,  
I also like to do substring matching and regular expressions quite a  
bit, and Boyer-Moore is definitely more efficient with arrays than  

It's probably worth noting that none of the languages which are  
considered _good_ for working with strings (AFAIK) use a list  


More information about the erlang-questions mailing list