[erlang-questions] List comprehension question

Rich Neswold rich.neswold@REDACTED
Tue May 27 13:40:04 CEST 2014

On Mon, May 26, 2014 at 3:50 AM, Dmitry Kolesnikov

> Hello,
> Your fist suggestion fails in shell with
> * 1: variable 'NC' unsafe in 'case' (line 2)

Yes, the compiler isn't smart enough to realize the false case will prevent
further evaluation. It's a false warning.

> The last suggestion with two generators looks pretty cool.
> I’ve got an impression that its complexity is N * log(N).

Why N * log(N)? With two generators, the complexity is O(N * M), but M, in
this case, is 1 so it should still be very close to O(N).

I'm glad you found the method useful, though.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140527/a4de8b33/attachment.htm>

More information about the erlang-questions mailing list