# Compiled expression with mixed types not working

**URL:** <https://community.wolfram.com/t/compiled-expression-with-mixed-types-not-working/4522>\
**Category:** Questions\
**Tags:** mathematica, compilation\
**Created:** [January 13, 2015, 8:44am UTC](https://community.wolfram.com/t/compiled-expression-with-mixed-types-not-working/4522 "2015-01-13T08:44:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyanfernando](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@priyanfernando](https://community.wolfram.com/u/priyanfernando)\
**Post date:** [January 13, 2015, 8:44am UTC](https://community.wolfram.com/t/compiled-expression-with-mixed-types-not-working/4522/1 "2015-01-13T08:44:58Z")

</div>

I have some sample code:

```
data1 = {{1, 2, 9}, {4, 5, 6}, {2, 5, 6}};
data2 = {{1, 2, "bob"}, {4, 5, 6}, {2, 5, 6}};
testfn1 = Compile[{{n, _Integer}}, Select[data1, #[[2]] == n &]]
testfn2 = Compile[{{n, _Integer}}, Select[data2, #[[2]] == n &]]

```

The only difference between data1 and data2 is that the latter has a string element “bob”. testfn1 and testfn2 simply splice the matrix.

```
In[904]:= testfn1[5]

Out[904]= {{4, 5, 6}, {2, 5, 6}}

```

The above code works fine. However:

```
In[905]:= testfn2[5]

During evaluation of In[905]:= CompiledFunction::cfte: Compiled expression {{1,2,bob},{4,5,6},{2,5,6}} should be a rank 2 tensor of machine-size real numbers. >>

During evaluation of In[905]:= CompiledFunction::cfex: Could not complete external evaluation at instruction 3; proceeding with uncompiled evaluation. >>

Out[905]= {{4, 5, 6}, {2, 5, 6}}

```

Why does data2 have to only have Real elements?

Thanks!

---

<div class="post-metadata">

**Author:** ![fkampas](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/fkampas/32/41217_2.png) [@fkampas](https://community.wolfram.com/u/fkampas)\
**Post date:** [January 13, 2015, 3:41pm UTC](https://community.wolfram.com/t/compiled-expression-with-mixed-types-not-working/4522/2 "2015-01-13T15:41:40Z")

</div>

Vector and tensor arguments to compiled functions need to all be a single type.
