Wolfram Language

Use File Operations in Compiled Code

The Wolfram Compiler is not limited to only use functions that are directly supported. It can use KernelFunction to call on all parts of the Wolfram Language. File operations like Put and Get often require the full kernel to evaluate and so cannot be compiled, but are still very useful in compiled functions.

Store some data to be read in.

The Typed annotation surrounding the KernelFunction declares that loader takes no arguments and returns a depth-1 array of real numbers.

The function returns the sum of the data. As the compiler had determined, the result is a real number.

Related Examples

ja