[erlang-questions] Is function clause selection O(n)?

Daniel Goertzen daniel.goertzen@REDACTED
Tue Jul 17 21:04:38 CEST 2007


I am considering the design of a filtering function that will prevent some
function calls and allow others.  For example, such a function might look
like this:

filter(M,F,Args) -> apply(M,F,Args).

Of course the above does no actual filtering, but for the use I'm
envisioning there will be dozens or even hundreds of clauses for the filter
function.  So, I am wondering what the algorithmic complexity of runtime
clause selection is.  O(n)?  O(log n)? O(1)?

I've also considered an ets table lookup for this, but it does the opposite
of what I want.  With ets you can specify a pattern to match against a set
of values, but I need a value to match against a list of patterns.

Any other ideas?

Thanks,
Dan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070717/c2d108cb/attachment.htm>


More information about the erlang-questions mailing list