-
Notifications
You must be signed in to change notification settings - Fork 306
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(x => basename(x))
- Apply function to each value of an array
#333
Comments
There was quite a bit of discussion on such things in #312. The general consensus seemed to be that such things are best left out of the WDL syntax. Adding such features would bring WDL closer to becoming a full-blown programming language, which will reduce the ease of cooperation in the development of workflows, understanding the code written by others and learning how to write WDL. Though such a syntax might be easily understood by many programmers, WDL was intended to be intelligible and easy to learn for non-programmers as well, to whom this would likely look like magic. Functionality like this can be achieved through the use of a task, in which you could write some (heredoc) python code. I haven't tested this but something like the following, in combination with the for x in ["~{sep='","' input_array}"]:
print(do_something(x)) |
If you're just getting basename, why not this?
and then |
I realised this is just a duplicate of #203, closing this. |
Hi, is there a way to apply a function to each value of an array. I'd like to get the basename (understanding there may potentially be name clashes) for each element in an array, and couldn't find a way to do this.
Other use cases, getting a bunch of strings from an array of files, eventually finding the max file-size of an array of files and more I'm sure.
If there's not a way, I think it might be something valuable you can do with some ideas:
array.map(el => my_function(el))
or `map_elements(iterable, el => my_function(el))[my_function(el) for el in iterable]
The text was updated successfully, but these errors were encountered: