<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 26, 2014 at 3:50 AM, Dmitry Kolesnikov <span dir="ltr"><<a href="mailto:dmkolesnikov@gmail.com" target="_blank">dmkolesnikov@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello,<div><br></div><div>Your fist suggestion fails in shell with</div><div>* 1: variable 'NC' unsafe in 'case' (line 2)</div>
</div></blockquote><div><br></div><div>Yes, the compiler isn't smart enough to realize the false case will prevent further evaluation. It's a false warning.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>The last suggestion with two generators looks pretty cool. <br></div><div>I’ve got an impression that its complexity is N * log(N). </div></div></blockquote><div><br></div><div>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).</div>
<div><br></div><div>I'm glad you found the method useful, though.</div><div> </div></div>-- <br>Rich<br>
</div></div>