Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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, ....}


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


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.

share|improve this question
Can't mix types like that directly (from the docs: "assumes that Subscript[x, i] is a rank Subscript[n, i] array of objects, each of a type that matches Subscript[t, i]. " (emphasis mine). – ciao Apr 27 '14 at 21:26
Strings cannot be compiled. – RunnyKine Apr 27 '14 at 21:27
Related question:… – blochwave May 19 at 21:35
You could convert input strings to integers and convert them back to strings in the output of the compiled function, if the strings are not supposed to change in the program. – faysou May 19 at 22:00

1 Answer 1

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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