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

.flatmap doesn't flatten #4937

Closed
p6rt opened this issue Dec 26, 2015 · 5 comments
Closed

.flatmap doesn't flatten #4937

p6rt opened this issue Dec 26, 2015 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Dec 26, 2015

Migrated from rt.perl.org#127036 (status was 'rejected')

Searchable as RT127036$

@p6rt
Copy link
Author

p6rt commented Dec 26, 2015

From @zoffixznet

It seems .flatmap method does not flatten.

Running the example in the docs produces wrong result​:
<ZoffixWin> m​: say ((1, 2), <a b>).flatmap(&uc).join('|');
<camelia> rakudo-moar a563e8​: OUTPUT«1 2|A B␤»

Also, this​:
<LLamaRider> m​: say ([1,2],[3,4]).flatmap({$^x}).perl; say ([1,2],[3,4]).flat.flatmap({$^x}).perl;
<camelia> rakudo-moar a563e8​: OUTPUT«($[1, 2], $[3, 4]).Seq␤(1, 2, 3, 4).Seq␤»

Relevant IRC conversation​: http://irclog.perlgeek.de/perl6/2015-12-26#i_11781049

@p6rt
Copy link
Author

p6rt commented Dec 27, 2015

From @zoffixznet

More cases with flat too​:

<AlexDaniel> m​: my @​a = (1, 2), 3; say flat @​a
<camelia> rakudo-moar 9441bb​: OUTPUT«((1 2) 3)␤»
<AlexDaniel> m​: my @​a = (1, 2), 3; say |@​a
<camelia> rakudo-moar 9441bb​: OUTPUT«(1 2)3␤»
<Zoffix> | is slip
<AlexDaniel> m​: my @​a = (1, 2), 3; say flat flat @​a
<camelia> rakudo-moar 9441bb​: OUTPUT«((1 2) 3)␤»
<AlexDaniel> m​: my @​a = (1, 2), 3; say flat flat flat flat @​a # dammit
<camelia> rakudo-moar 9441bb​: OUTPUT«((1 2) 3)␤»

http://irclog.perlgeek.de/perl6/2015-12-27#i_11787064

@p6rt
Copy link
Author

p6rt commented Dec 28, 2015

From @niner

Arrays itemize their elements. Itemized are never flattened, even when explicitly flattening the array. You need to recursively walk through the nested data structure either by converting everything into Slips or using gather/take or something else.

@p6rt
Copy link
Author

p6rt commented Dec 28, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 18, 2016

@zoffixznet - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jun 18, 2016
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