Fri, 20 Aug 1999 15:57:51 +0200 (CEST), xander <[EMAIL PROTECTED]> pisze:

> is there an opposite (:) available in haskell?
[...]

Sometimes it suffices to create the list backwards and reverse it at
the end. This is O(n) instead of O(n^2) for repeated (++[x]).

I think that composing a list by (.) from (x:)'s instead of by (:)
from x's should be good, although I'm not sure how good comparing to
(:)'s at the beginning of the list. It means that a list is represented
by the function concatenating the list to the argument. Such functions
can be glued by function composition, also from equal big parts.

Using (some_string++) as the component is OK - if I understand the
issue correctly, the point is to avoid multiple ++'s walking (and
duplicating the list skeleton) along _the same list_ (when it is later
a part of a larger list). That is, the point is in making ++'s composed
as a++(b++(c++d)), not ((a++b)++c)++d, even though the result will be
the same - but the cost is not the same. So (a++).(b++), equivalent to
(\s -> a++b++s), is better than ((a++b)++) when a is long.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://kki.net.pl/qrczak/
 \__/          GCS/M d- s+:-- a22 C+++>+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP->+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-



Reply via email to