News for hackers. Stuff that matters.
Re:Toolz: A functional standard library for Python by diarrhea on Thursday January 21, 2021 @04:35PM (#25864599)
This works for conditionals:

    In [4]: f = lambda x: "Yes" if x else "No"

    In [5]: f(True)
    Out[5]: 'Yes'

    In [6]: f(False)
    Out[6]: 'No'
It's Python's version of ternary operators, so not sure if that counts as a "true" conditional; but it is one.

Loops don't work, but list comprehensions do, and they are definitely the way to go here. Multi-line loops deserve a `def`.

There are no comments on this comment yet.