question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

engine function to map over an Array

See original GitHub issue

There’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:open
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
dheimancommented, Sep 4, 2018

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).

2reactions
illusionalcommented, May 7, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found