Steve Yegge's rant on The Next Big Language

janderson askme at me.com
Sun Mar 11 11:52:15 PDT 2007


Jarrett Billingsley wrote:
> 
> Basically it's a way of really easily applying functions and such over a 
> list.  They're kind of like array operations (a[] = b[] + c[]), which D 
> doesn't have yet, but more flexible.  You can do stuff like (using very 
> python-like syntax):
> 
> int[] numbers = [1, 2, 3, 4, 5, 6, 7, 8];
> 
> // This loops through numbers, seeing if the condition holds true,
> // and if it does, adds it to a new list, which is eventually assigned
> // to evens.
> int[] evens = [x for x in numbers if !(x & 1)];
> 
> // Square the list
> int[] squares = [x * x for x in numbers];

I'm not sure about these.  The syntax is not much better then a foreach 
loop.



More information about the Digitalmars-d-announce mailing list