Apply higher-order function

Can I call a function that has a number of arguments specified at runtime?

I would have thought it possible with currying. But this doesn’t compile:

https://rescript-lang.org/try?code=FAGwpgLgBAZlC8UAUBDANFARhgxhgJhmAJQIB8UKUA1FjVDvfvWMKJLAOQKxICMxNuGgxO3RKP4AGQe2goADgpABPHkhgA7DNqggAzhFLwKAb2BQ9HFHx5akBiAG0pAXUGWAlnE1QKt80tLYUoAJh4bB0MnPncLIO8oXwpwwKDLFFCo51C49IBfeMswAzAoU0zCyyqoEv0yir5CwuBFZRUNMQwAZgwYqSkMPgHBqGGRuKA

Ah, but if I write f in curried form I should not need apply:

let f = a => (b => (c => (d => (e => a+b+c+d+e))))

Can I use reduce with that?

What type is the apply function supposed to return?

It’s not compiling because the branches of this conditional return different types. a2(lst[2]) is int and a2 is int => int

    if n > 2 {
      a2(lst[2])
    } else {
      a2
    }