-
Notifications
You must be signed in to change notification settings - Fork 67
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
Call a function on every element of a complex value #4610
Comments
This is a function that applies a function to every element in an array or set value. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
The map function that applies a function to every element in an array or set value. Also: rename the map aggregator to collect_map to avoid collision with this new function. Closes #4610
#4806 implements a solution for arrays and sets but for not maps or records. |
Here's verification in Zed commit 3a40788 of the Revisiting the original example above, instead of the
Of course, built-in functions work as well.
However, while verifying, I did spot what I think is a bug that's now tracked in #4855. I've also proposed some minor doc fixes in #4856. Thanks @mattnibs! |
Related: When discussing the |
Repro is with Zed commit efdcd27.
Imagine you have an complex value such as the array of numbers
[1, 4, 9, 16]
and you want to execute some function on each element to produce a new array, such as multiplying each element by two. To accomplish this in Zed today requires a multi-part idiom:Compare this to something like JavaScript's
map()
(not to be confused with Zed'smap
type) which can perform the equivalent in one shot. We've recognized Zed should offer a similar shorthand.While in JavaScript we see this approach applied to array types, it seems that in Zed it could be used for not only arrays but also sets, maybe maps, and perhaps into records (recursively?) though I'm not sure. Implementation TBD, I suppose.
The text was updated successfully, but these errors were encountered: