Is there a way to Compile a function whose argument is a list of integers, the list having unknown length ? For example, Max ?

  • 1
    $\begingroup$ No. Use a integer vector argument instead. And there is no point in compiling Max because it is already compiled. $\endgroup$ Feb 20, 2018 at 19:43

1 Answer 1


The number of arguments must be known at compile-time. However, if you want to provide arguments of the same type, you can simply pass them as a list instead of single arguments

max = Compile[{{list, _Integer, 1}}, Max[list]]
max[{1, 2, 3}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.