engine function to map over an Array
See original GitHub issueThere’s currently one main function (prefix) that maps over all the elements in an array. When one wants to do some other kind of mapping/manipulation over all the elements in an array, they can do so by using a scatter block:
Array[String] arr = ['a', 'b', 'c']
scatter (i in arr) {
String append_suffix = i + '_1'
}
Array[String] arr_with_suffix = append_suffix # ['a_1', 'b_1', 'c_1']
It would be great if there was an engine function that allowed for running functions over an Array type without requiring the boilerplate of a scatter block.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How To Use .map() to Iterate Through Array Items in JavaScript
One of the most popular methods is the .map() method. .map() creates an array from calling a specific function on each item in...
Read more >Mapping an array of functions over an array in Javascript
to several arrays(channels) of float data) so I have written a helper function... const mapMany = function(processors, channels){ processors.
Read more >Use this trick to map over single objects in Javascript
If we'll try to iterate over the result, .map() won't work so we'll ... Since .map() iterates over single entry arrays, we won't...
Read more >Array.prototype.map() - JavaScript - MDN Web Docs
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array....
Read more >JavaScript Array Map - YouTube
JavaScript Array Map Get the COMPLETE course (83% OFF - LIMITED TIME ONLY): http://bit.ly/2KZea52Subscribe for more videos: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Another possible suggestion is to follow the path of vectorized languages like R or MATLAB (which in my experience are the two most common languages used by bioinformatics researches), and simply have functions be Array-aware. That is, if a scalar function that takes scalar input is run on an array, a new array is returned with each value being the result of that scalar function being run on the corresponding value of the input array (implicit map).
Hey @patmagee, is there any way to gain some momentum on this feature request? Is list comprehension an acceptable approach? I’m happy to target something against a spec and implement it in MiniWDL maybe?