Skip to main content

How to compile a function whose arguments are lists containing strings?



I'm unsuccessfully trying to compile this function


check[argA_, argB_] := argA[[1]] == argB[[1]];

assuming that both arguments argA and argB are of the form


{Real, String, ....}

Neither


cf = Compile[
{
{x, {_Real, _String}, 1},

{y, {_Real, _String}, 1}
},
x[[1]] == y[[1]]
];

nor


cf = Compile[
{
{x, {_Real, _String}, {1}},
{y, {_Real, _String}, {1}}

},
x[[1]] == y[[1]]
];

work as expected, and I can't see the underlying rule. I'm grateful for any explaination.



Answer



As @RunnyKine comments, String arguments cannot be compiled. From the documentation:



The types handled by Compile are:




  • _Integer machine‐size integer

  • _Real machine‐precision approximate real number (default)

  • _Complex machine‐precision approximate complex number

  • True | False logical variable



Comments