Erlang does have problems

Bob Ippolito bob@REDACTED
Thu Aug 31 05:44:36 CEST 2006

On 8/30/06, Scott Lystig Fritchie <fritchie@REDACTED> wrote:
> >>>>> "bi" == Bob Ippolito <bob@REDACTED> writes:
> bi> I'm also not terribly convinced that lists are better for
> bi> concatenation, because adding data to the end of a list requires a
> bi> lot of copying and that's the most common operation in my
> bi> experience.
> Oh?  At last check, "X = [A, B]" executed in O(1) time regardless of
> the sizes of A & B.  As far as I/O lists are concerned,
> [<<"fo">>, [[], $o], [[[<<"ba">>]], <<"r">>]] yields the same effect as
> <<"foobar">>.
> If whatever library you're working can only tolerate "flat" lists(*),
> then you're limited to O(length(A)) concatenation (lists:append/2, A
> ++ B, etc).

I was referring to the stdlib string library (and the idea of
"string()" in general, as far as Erlang documentation goes), which
refers to exactly "flat" lists of integers. Sure, it's possible to
write a string library that can work with iolists, and that'd be
great, but Erlang doesn't ship with one as far as I can tell.

1> string:tokens("foo|bar|baz", "|").
2> string:tokens(["foo", ["|bar|", "baz"]], "|").


More information about the erlang-questions mailing list