ACCEPTABLE?: List Comprehensions?
i30817 at gmail.com
Mon Mar 16 13:48:12 PDT 2009
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:
List<Integer> out = [x for x : in]
List<Integer> out = [x+valueToAdd for x : in]
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 :
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 :
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
If you see the nested fors example you see i'm contracting myself, viz ";"
I leave the field to the experts, but please make the main usecase the
More information about the coin-dev