efficiency, deep lists
Luke Gorrie
luke@REDACTED
Tue Oct 2 14:11:06 CEST 2001
Luke Gorrie <luke@REDACTED> writes:
> Ulf Wiger <etxuwig@REDACTED> writes:
>
> > I've been playing around with continuation passing style when
> > processing lists of lists. It does seem to be a bit cheaper than
> > the alternative styles. If funs are optimized in R8, it should be
> > even more so.
>
> I'll throw in another continuation-based version (for any-depth
> lists):
For benchmarking, here's the list-of-lists version, which is just
Ulf's incr2 with the recursive call moved from where the continuation
is created to where the continuation is invoked:
incr6([H|T]) when list(H) ->
incr66(H, T);
incr6([]) ->
[].
incr66([H|T], C) ->
[H+1|incr66(T, C)];
incr66([], C) ->
incr6(C).
Ulf, I'd be interested to know how it runs in the benchmark, since you
seem to have a way of timing things better than us (maybe a Solaris
thing?).
--
Favourite Haiku error: Three things are certain:
Death, taxes, and lost data.
Guess which has occurred.
More information about the erlang-questions
mailing list