Python Lambdas e List Comprehension

Um modo de criar novas listas no python utilizando List Comprehension

new_list = [apply(i) for i in old_list if filter(i)]

Com Lambdas

Também podemos utilizar lambdas para mapear listas em novas listas.

new_list = map(lambda v : v * 5, old_list)

Posted

in

,

Written by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *