[Python] Clean code for sequence of map/filter/reduce functions

Discussão em 'Python' iniciado por Stack, Dezembro 22, 2024.

  1. Stack

    Stack Membro Participativo

    Is there a simple way to code in one line a sequence of map/filter/reduce functions?

    For example instead of:

    reduce(lambda x, y: x*y, filter(lambda x: x>0, map(lambda x: x - 1, some_list)))


    I am looking for something like:

    some_list.map(lambda x: x -1, a).filter(lambda x: x>0).reduce(lambda x, y: x*y)

    Continue reading...

Compartilhe esta Página