(define-external (build_list (int n) (scheme-object lst))
scheme-object
(cons n lst) )
#>!
__callback __scheme_value my_iota(int n)
{
int i;
__scheme_value lst = C_SCHEME_END_OF_LIST;
for(i = n - 1; i >= 0; --i)
lst = build_list(i, lst);
return lst;
}
<#
(print (my_iota 10))
The same, in a different form:
(define-external (build_list (int n) (scheme-object lst))
scheme-object
(cons n lst) )
(define my-iota
(foreign-callback-lambda* scheme-object ([int n]) #<<EOF
int i;
__scheme_value lst = C_SCHEME_END_OF_LIST;
for(i = n - 1; i >= 0; --i)
lst = build_list(i, lst);
return(lst); /* note the parens */
}
EOF
))
(print (my_iota 10))
-- BunnyBunny - 22 Jun 2004