In DolphinDB, how to deal with mutable arguments in a concise way?

26 Views Asked by At

In the function makeCall(F, args...), args are the required arguments of F. When F involves multiple arguments, I currently use the if-else statement and write the makeCall function as follows to determine the number of arguments:

makeCall(f1,sqlCol(args[0])), or

makeCall(f2,sqlCol(args[0]),sqlCol(args[1])), or

makeCall(f3,sqlCol(args[0]),sqlCol(args[1]),sqlCol(args[2])).

However, as the number of arguments in F increases, the script becomes lengthy due to the increasing number of if-else statements. Is there a concise way to pass the arguments in args to the makeCall function?

1

There are 1 best solutions below

0
On BEST ANSWER

You can use the makeUnifiedCall function which encapsulates all input arguments into a tuple, so that you don't need to worry about the number of arguments. When passing arguments, you can initialize a tuple for args of makeUnifiedCall as follows (param for example) and use append! to add arguments.

param = []
param.append!(x)
param.append!(y)