How to replace for-loops with a functional statement in C#?

Functional constructs often express your intent more clearly than for-loops in cases where you operate on some data set and want to transform, filter or aggregate the elements. Loops are very appropriate when you want to repeatedly execute some action. For example int x = array.Sum(); much more clearly expresses your intent than int x … Read more

When implementing an infinite loop, is there a difference in using while(1) vs for(;;) vs goto (in C)?

They are equivalent, even if you turn the optimizer off. Example: #include <stdio.h> extern void f(void) { while(1) { putchar(‘ ‘); } } extern void g(void) { for(;;){ putchar(‘ ‘); } } extern void h(void) { z: putchar(‘ ‘); goto z; } Compile with gcc -O0 gives equivalent assembly for all 3 functions: f: ; … Read more

Python `for` syntax: block code vs single line generator expressions

What you are pointing to is Generator in Python. Take a look at: – http://wiki.python.org/moin/Generators http://www.python.org/dev/peps/pep-0255/ http://docs.python.org/whatsnew/2.5.html#pep-342-new-generator-features See the documentation: – Generator Expression which contains exactly the same example you have posted From the documentation: – Generators are a simple and powerful tool for creating iterators. They are written like regular functions but use the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)