[erlang-questions] '--' BIF to be used with caution?

Hynek Vychodil vychodil.hynek@REDACTED
Tue Jan 13 17:02:59 CET 2009

'--' have O(N.M) complexity, if you suspect big M use you own O(M+N.logM)
implementation. Do not use '--' for big M.

2009/1/13 Malcolm Dowse <malcolm@REDACTED>

> Hello,
> I ran into an issue with Erlang the other day. I'm not sure if it's a bug,
> but I thought I should warn others.
> I was using '--' to get the difference between two large lists. As expected
> it was very slow, but, to my surprise, ERTS became completely unresponsive
> for a long time. (Only one CPU was maxed out, and there was still plenty of
> memory available.)
> To reproduce (on Ubuntu 7.x, R12B-x), open an Erlang shell and type:
> spawn(fun() -> lists:seq(1,1000000) -- lists:seq(1,1000000,2) end).
> The unresponsiveness seems to be caused by '--' being a BIF. Is there a
> good reason for making it a BIF if it's not always an improvement?
> All the best,
> Malcolm
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill your
boss.  Be a data hero!
Try Good Data now for free: www.gooddata.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090113/4c39acbb/attachment.htm>

More information about the erlang-questions mailing list