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

Support non-bijective mapping with Map #201

Open
randomir opened this issue Sep 14, 2019 · 0 comments
Open

Support non-bijective mapping with Map #201

randomir opened this issue Sep 14, 2019 · 0 comments
Labels
feature New feature or request

Comments

@randomir
Copy link
Member

Map can easily be generalized to support non-bijective mapping, at least in surjective sense (dropping some outputs).

The same can be achieved with map | filter flow, but sometimes non-emitting the output can be done more easily.

Usage example:

class IncOdd(Runnable):
    def next(self, state):
        if state.number % 2:
            return state.updated(number=state.number + 1)

inp = States(*(State(number=i) for i in range(5)))
out = Map(IncOdd()).run(inp).result()

exp = States(State(number=1), State(number=3))
assert out == exp
@randomir randomir added the feature New feature or request label Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant