The following C function returns the last letter of a string.
char last_letter( char *s )
|
{
|
return( s[strlen(s)-1] );
|
}
|
|
|
In Maple, this can be used as follows.
>
|
|
The following C function doubles the input.
void times2( int *i )
|
{
|
if( !i ) return;
|
*i *= 2;
|
}
|
|
|
In Maple this can be used as follows.
>
|
|
The uneval quotes are needed to prevent evaluation of the name, 'n' so the external function can get the name, rather than its assigned value. Without the quotes the value is still passed, but the variable 'n' is not updated.
The following Java function adds up all the elements of a Matrix.
public class jexttest
|
{
|
public static double sum_elems( double[] a, int num_elems )
|
{
|
int i;
|
double r = 0.0;
|
for( i=0; i<num_elems; ++i )
|
r += a[i];
|
return( r );
|
}
|
}
|
|
|
In Maple this can be used as follows.
>
|
|
>
|
|