Pymba - Python functional statements

Pymbda is a library that I wrote which turns a few Python statements into functions. It’s not quite Hylang, but it’s as functional as Python can be.

Right now there are four functions: if_, ifelse, tryexcept, and with_

if_ takes a predicate function or an object as its first parameter, and will either evaluate the function or check the truthiness of the first parameter. if true it will execute the second parameter as a function.

for x in range(10):
    if_((lambda x: x%2 == 0)(x), lambda: print(x))

map(lambda x: if_(x%2==0, 
                  lambda: print(x)
              ), 
              range(10))

tryexcept allows try/except statements to be used as a lambda function

tryexcept(lambda: THIS_BREAKS_THE_FUNCTION, lambda: print('bad argument'), NameError)

- to blog -

blog built using the cayman-theme by Jason Long. LICENSE