# ACCEPTABLE?: List Comprehensions?

Paulo Levi i30817 at gmail.com
Mon Mar 16 13:48:12 PDT 2009

```I dunno.
The major line reduction win is in the nested fors example, but most of the
fors i make with a list output are not nested. I would just like that this
proposal also adapts to the simple zip or multi-map usage.

Lets see if i understand it:
Simple copy:
List<Integer> out = [x for x : in]
Simple map:
List<Integer> out = [x+valueToAdd for x : in]
Multi-map :
List<Integer> out = [x+valueToAdd, x+3 for x : in] (output list.size =
in.size * 2)
List<Integer> out = [x+valueToAdd if x % 2 == 0, x+3 if x % 2 != 0 for x :
in]
Zip:
List<Integer> out = [x+valueToAdd, y+3 for x : in, y : in2]
List<Integer> out = [x+valueToAdd if x % 2 == 0, y+3 if x % 2 == 0 for x :
in, y : in2]
Nested fors (only 1 condiction allowed):
[ a + b + c, if a > 5 && c < 2,  for a : intList1, for b : intList, for c :
intList]

The nested for is the most bizarre and unusual example of all.
I see why you put the condition after the for, but i think that is a little