-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
map over nested structures #33920
Comments
Like this? |
Sounds like another reason to want #24990, with which you could write |
Between the suggestion above and the zillion underscore proposals and PRs out there, I think we can close this but feel free to undo if anyone disagrees! |
See |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd like to write something concise to turn
[(1, 2), ((3, 4), (5, [7, 8]))]
into
[(1.0, 2.0), ((3.0, 4.0), (5.0, [7.0, 8.0]))]
If the structures are "uniformly" nested, one idea from @ssfrr is to e.g. define
fmap(f) = x->map(f,x)
then
You can then use whatever idiom for iterated functions to concisely write deeply but uniformly nested structures.
For non-uniformly nested structures, there's a question about how deep to apply the function. I'm not sure what a good generic API for what I want would be.
Related:
#32081 (comment)
#32796
#20502
The text was updated successfully, but these errors were encountered: