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 description is wrong #851

Closed
smls opened this issue Aug 22, 2016 · 1 comment
Closed

flatmap description is wrong #851

smls opened this issue Aug 22, 2016 · 1 comment
Labels
docs Documentation issue (primary issue type)

Comments

@smls
Copy link
Contributor

smls commented Aug 22, 2016

https://docs.perl6.org/type/List#method_flatmap incorrectly suggests that flatmap flattenes the input list before iterating it, when in fact it seems to flatten the result of the map operation:

dd ((1, 2), <a b>).map({ $_, $_ });      # (((1, 2), (1, 2)), (("a", "b"), ("a", "b"))).Seq
dd ((1, 2), <a b>).flatmap({ $_, $_ });  # (1, 2, 1, 2, "a", "b", "a", "b").Seq

The example given on the page should be removed altogether, as it lies about &uc being called four times (it's called twice, once for each element of the input list), and doesn't produce a nested output so there's nothing to flatten, and thus fails to demonstrate what flatmap actually does.

@smls smls added the docs Documentation issue (primary issue type) label Aug 22, 2016
samcv added a commit that referenced this issue Jun 24, 2017
The previous example's explanation was wrong, and the example
had the same result on both .map and .flatmap, making it an
even more confusing function.

The documentation now strongly recommends use of .map.flat and
recommends to instead using the confusing .flatmap

Fixes issue #851.
@samcv
Copy link
Collaborator

samcv commented Jun 24, 2017

Fixed after a year! Yay! 🎉 🎈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type)
Projects
None yet
Development

No branches or pull requests

2 participants