Staged transformations are transformations applied to a set of data in stages.

Lets say I want the following to happen.

Given a list [1,2,3,4,5,…, 100]

1. Square all odd numbers

2. Cube all even numbers

3. Let the numbers from the above calculations should be stored in 1 list.

Hence we should get [1, 8, 9, 64, 25, …]

4. Now in this list add 3 to all even numbers and 2 to all odd numbers

Final o/p: [3,11,11,67,27,…]

We can simplify the code a lot…

https://www.dropbox.com/s/enzdl6h7anh5llm/staged.py

### Like this:

Like Loading...

*Related*