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

Make [Iterable|Stream].expand argument optional #8738

Open
DartBot opened this issue Feb 22, 2013 · 3 comments
Open

Make [Iterable|Stream].expand argument optional #8738

DartBot opened this issue Feb 22, 2013 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-n P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Feb 22, 2013

This issue was originally filed by @seaneagan


It would be nice if [Iterable|Stream].expand's argument were an optional positional and defaulted to:

(x) => x is Iterable ? x : [x]

It could alternatively be recursive:

(x) => x is Iterable ? x.expand() : [x]

... but that could lead to cycles, and a more generic way to recursively walk an Iterable might be better:

void walk(f) => forEach((x) => x is Iterable ? x.walk(f) : f(x));

then you could just do:

var flattened = [];
iterable.walk(flattened.add);

@DartBot
Copy link
Author

DartBot commented Feb 23, 2013

This comment was originally written by ladicek@gmail.com


Or maybe just add a 'flatten' method.

@DartBot
Copy link
Author

DartBot commented Feb 23, 2013

This comment was originally written by @seaneagan


Yeah, actually I'm not sure why I would ever use "expand" if I had a lazy "flatten":

Iterable<E> flatten({bool recursive = false});

Then:

iterable.expand(f)

is just replaced by:

iterable.map(f).flatten();

@lrhn
Copy link
Member

lrhn commented Feb 25, 2013

Removed Type-Defect label.
Added Type-Enhancement, Area-Library, Triaged labels.

@DartBot DartBot added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Feb 25, 2013
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Feb 29, 2016
@lrhn lrhn added the core-m label Aug 11, 2017
@floitschG floitschG added core-n and removed core-m labels Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. core-n P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants