Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New functionalities #15

Open
znittzel opened this issue Mar 29, 2023 · 0 comments
Open

New functionalities #15

znittzel opened this issue Mar 29, 2023 · 0 comments

Comments

@znittzel
Copy link
Contributor

Drop here new function proposals.

Here is one:

class constant:

    """
        Returns a function that no matter the arguments
        always returns self.value.
    """
    def __init__(self, value):
        self.value = value

    def __call__(self, *args, **kwargs):
        return self.value

This one is good for whenever you want a constant value but some other function requires a function as input. E.g.

maz.ifttt(
    lambda x: x > 0,
    lambda x: x+1,
    constant(0),

This differ from doing lambda: 0 since that one would require zero arguments and would crash in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant