Hi,
Is their equivalent codes for ff in perl 6 ?
I've been told there is none in O'Caml as pointer is not available.
[EMAIL PROTECTED] oscarp]# cat f.c
int main(void)
{
int (*get_f())();
static int arr[] = { -1, 0, 1, 0, 2, +9, +3200, -3500 };
int *ptr, *pastend;
int (*fptr)();
pastend = arr + sizeof(arr)/sizeof(arr[0]);
for (ptr = arr; ptr < pastend; ptr++)
if (fptr = get_f(ptr))
fptr(ptr);
return 0;
}
int (*get_f(ptr))()
int *ptr;
{
int is_neg(), is_pos();
static int (*cmds[])() = {
(int (*)())0,
is_neg,
is_pos
};
int index = 0;
if (*ptr < 0)
index = 1;
if (*ptr > 0)
index = 2;
return(cmds[index]);
}
is_neg (iptr)
int *iptr;
{
printf("%d is negative\n", *iptr);
}
is_pos (iptr)
int *iptr;
{
printf("%d is positive\n", *iptr);
}
--
O Plameras
http://www.acay.com.au/~oscarp/tutor
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html