[erlang-questions] traversal of multiple lists (or list of lists)

Karlo Kuna kuna.prime@REDACTED
Fri Oct 21 22:41:40 CEST 2016


i want to implement what i call Select-Consume function:

take list of lists [L1 ... Ln]
select some (potentially all) heads from L1 ... Ln and do something with
them
recurse with tails of lists where selection happened and with complete
lists where there wasn't selection preserving original order
end when all L1 ... Ln are exhausted or when there was no selected heads.

my worry is about performance, as far as i know in erlang there is no way
to coordinate traversal of multiple lists!
i looked at implementation of lists module and there i found horror of
manual implementation of case combinatorics in merge/3
which obviously does not scale at all.
i am also aware that forwarding strategy in my case is making new list
every time, which is BAD but i don't know of any other way
to handle variadic function call other than passing list of arguments (in
my case list of lists)

i'm wandering is my problem somewhat "hard" for erlang and what are
solutions if any ??

thanks for any help

Kuna Prime
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161021/8393b72c/attachment.htm>


More information about the erlang-questions mailing list