chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] passing variable number of floats to C


From: Heinrich Taube
Subject: Re: [Chicken-users] passing variable number of floats to C
Date: Tue, 19 Feb 2008 13:32:02 -0600

thanks, i see now. since its a list it would be nice from the users perspective to be able to pass immediate ints in addition to floats without having to cons the floats on the scheme side. so on the c side ill have to make sure that the car is either an int or a float before i access it -- ive been poking around in the doc but dont see any obvious predicates to do this. can you please point me in the right direction? thanks for your help!

for ( ; C_SCHEME_END_OF_LIST != lyst; lyst = C_u_i_cdr( lyst )) {
 if ( IS_INT(C_u_i_car(lyst)) )
   sum += (double)C_u_i_car(lyst) ;
 else if ( IS_FLOAT(C_u_i_car(lyst))
   sum += C_u_i_car(lyst) ;
}





But this works:

#>
static double
double_sum( C_word lyst )
{
  double sum = 0.0;
  for ( ; C_SCHEME_END_OF_LIST != lyst; lyst = C_u_i_cdr( lyst )) {
    sum += C_flonum_magnitude( C_u_i_car( lyst ) );
  }
  return sum;
}
<#




reply via email to

[Prev in Thread] Current Thread [Next in Thread]