I am using Mathematica 12.2 with MacOS, and I do this:


Below we see this function returns a DataStructure, and we can use Normal to make the result a List we can work with. randFunc example Next I use the above Function in FunctionCompile.


I find it strange that this version returns a list we can work with. rand example

Anyway I like the two step process above. First I write a pure function and ensure it works correctly. Then I use the pure function in CompileFunction, and it takes a while to compile.

  • 1
    $\begingroup$ Yes, I am surprised, but rather more with the uncompiled version than the compiled one. The reason for my surprise is the fact that in the last line of your code you convert the dynamic array into packed array. Returning a packed array in a compiled function is standard, and should also work in the uncompiled version. In fact that it returns a dynamic array appears to me to be a bug. $\endgroup$ Oct 1, 2023 at 12:43


Your Answer

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

Browse other questions tagged or ask your own question.