4
$\begingroup$

When compiling below code

Compile[{{data, _Integer, 2}}, Fold[Flatten /@ Flatten[Outer[List, ##, 1], 1] &, data]]

I encountered error messages

Compile::cset: Variable Compile`Variable$8984 of type {_Integer,1} encountered in assignment of type {_Integer,2}.

Compile::extscalar: CompileVariable$8984=Flatten/@Flatten[Outer[List,Compile`Variable$8984,CompileGetElement[Compile`Variable$8985,Compile`Variable$8986],1],1] cannot be compiled and will be evaluated externally. The result is assumed to be of type Void.

Compile::cset: Variable Compile`Variable$8984 of type {_Integer,1} encountered in assignment of type {_Integer,2}.

Compile::extscalar: CompileVariable$8984=Flatten/@Flatten[Outer[List,Compile`Variable$8984,CompileGetElement[Compile`Variable$8985,Compile`Variable$8986],1],1] cannot be compiled and will be evaluated externally. The result is assumed to be of type Void.

I have no assignment in my code, Why such an error? How to deal with it and compile code successfully?

$\endgroup$
1
  • $\begingroup$ The simpler Compile[{}, Fold[Outer[Times, ##, 1] &, {{3}}]] already triggers Compile::cset. $\endgroup$ Sep 1, 2016 at 20:47

0

Your Answer

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