array comprehensions can pass the index

This commit is contained in:
Jeremy Ashkenas
2009-12-15 11:14:14 -05:00
parent 4480900d61
commit a0f4c9f3ba
4 changed files with 400 additions and 371 deletions

View File

@@ -1,4 +1,5 @@
# TODO: switch/case statements
# Make array comprehensions expressions. (return the computed array).
# Think of a name for this crazy thing.
# Functions:
@@ -100,4 +101,4 @@ b: 20
print(food.capitalize()) for food in ['toast', 'wine', 'cheese'].
cooler: ['soda', 'wine', 'lemonade']
drink(bottle) for bottle in cooler if bottle is 'lemonade'.
drink(bottle) for bottle, i in cooler if even(i).