ACCEPTABLE?: List Comprehensions?

Paulo Levi i30817 at gmail.com
Mon Mar 16 10:16:30 PDT 2009


I would love list comprehensions, but only if they were amenable to using
all kinds of statements there  (methods) and many comprehension statements
in one list.

List<Integer> input ....
List<Integer> out = [x + valueToAdd for x : input if x % 2 == 0; x +
valueToAdd + 2 for x : input];
Possibly this could be compressed for the same list (as here) to:
List<Integer> out = [x + valueToAdd if x % 2 == 0, x + valueToAdd + 2 for x
: in];
With only one iteration needed.

Would LOVE this.



More information about the coin-dev mailing list