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

Add support for expand #207

Open
dickermoshe opened this issue Nov 27, 2024 · 1 comment
Open

Add support for expand #207

dickermoshe opened this issue Nov 27, 2024 · 1 comment

Comments

@dickermoshe
Copy link

dickermoshe commented Nov 27, 2024

e.g.

class Foo:
  ...

class Bar:
  foo:Foo


bars = [Bar(), Bar(), Bar()]
foos =  Iter(bars).exapnd(lambda x: x.foo) # List of foos
print(foos)
 [Foo(), Foo(), Foo()]

Inspiration from https://api.dart.dev/stable/2.8.2/dart-core/Iterable/expand.html

@MartinBernstorff
Copy link
Owner

MartinBernstorff commented Nov 27, 2024

Thanks a lot for the suggestion! By default, I'd like this project to have a consistent API and, somewhat arbitrarily, we're leaning on rust for that (as written in the readme).

If you can find a comparable API on:

My impression is that you example is equal to:

Iter(bars).map(lambda x: x.foo)

And the linked example from dart is equal to:

Iter([1,2], [3,4]).flatten() # [1,2,3,4]

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

2 participants