Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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

Comment on Re: Recursing in XS?
Download Code

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 contemplating the Monastery: (3)
As of 2016-02-06 01:03 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (211 votes), past polls