Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Recursing in XS?

by syphilis (Chancellor)
on Apr 19, 2013 at 06:57 UTC ( #1029464=note: print w/replies, xml ) Need Help??

in reply to Recursing in XS?

Here's an XS file for a module and package My::Mod.
It contains a function named foo() that recursively calls itself until the supplied integer argument has been incremented to 20 (whereupon it returns the value '20').
If the supplied integer argument is >= 20, it returns that value immediately ... and if the supplied integer argument is a *lot* less than 20, then it might take a while to complete.
#include "EXTERN.h" #include "perl.h" #include "XSUB.h" int foo(int x) { if(x >= 20) return x; x++; x = foo(x); } MODULE = My::Mod PACKAGE = My::Mod PROTOTYPES: DISABLE int foo (x) int x

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029464]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2016-10-21 18:32 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.