Happy new year, everyone! I hope this is a good one.
The title doesn't really express well what I want to do, however, please see further explenation below.
Say, I have a list of functions flist
- {f,g,h}
where function f
takes three arguments; function g
takes six arguments; and function h
takes four arguments. Furthermore, I have an argument list alist
with randomly generated numbers which will serve as an input to the above functions.
How could I apply argument list alist
to flist
in such a way where each function in flist
would take appropriate subset of elements from alist
; whilst ensuring functions in flist
do not share elements from alist
.
Example
flist = {f,g,h};
alist = {1,2,3,4,5,6,7,8,9,10,11,12,13};
~magic~
f[1,2,3]
g[4,5,6,7,8,9]
h[10,11,12,13]
I know I could do something like
f @@ alist[[;;3]]
g @@ alist[[4;;9]]
h @@ alist[[10;;13]]
This said, I was wondering if there is a better way to do it. A more ~lazy~ approach.