Example of incorrect function application:
int[n:shp,m:inner]
take(int[n] shp, int[n:outer,m:inner] arr)
{
return { iv -> arr[iv] | iv < shp };
}
int main()
{
arr = genarray ([3,5], 0);
res = take ([1,2,3], arr);
return res[0,0];
}
Produces an error: Type pattern error in application of take: dimensionality of argument 'arr' is too small, could not assign a non-negative value to 'm' in 'm:inner'
Example of incorrect function definition:
int[n:shp,m:inner]
take(int[n] shp, int[n:outer,m:inner] arr)
{
return { iv -> arr[iv] | iv <= shp };
// <= instead of < here ^^^^
}
int main()
{
arr = genarray ([3,5], 0);
res = take ([1,2], arr);
return res[0,0];
}
Produces an error: Type pattern error in definition of take: the found value of 'shp' in 'n:shp' of return value is not equal to the value of argument 'shp'