[OctDev] Suport octave rescursive function?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[OctDev] Suport octave rescursive function?

Pedro Antonio Fructuoso Merino
Hi all,
    Suport octave rescursive function? In this case, how can I implement
it? I'm trying something like that:
        function res = test(a)
            if (a>0)
            j = test(a)
                res = a + j,
            else
                res = 0;
            endif
        endfunction
    but it's fauls...
       Pedro



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Suport octave rescursive function?

Thomas Weber-2
Hi,

Am Montag, den 07.11.2005, 09:48 +0100 schrieb Pedro Antonio Fructuoso
Merino:
> Hi all,
>     Suport octave rescursive function?
Yes.

> In this case, how can I implement it?
http://www.octave.org/doc/Recursion.html#Recursion

>     but it's fauls...
Please post a working example of your code (that is, a stripped down
example of the failing code). Otherwise it's just guessing.

Regards
        Thomas



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Suport octave rescursive function?

Pedro Antonio Fructuoso Merino
Thomas Weber escribió:
Please post a working example of your code (that is, a stripped down
example of the failing code). Otherwise it's just guessing.

  
I posted my code in last mail... the code was:
       function res = test(a)
           if (a>0)
           j = test(a)
               res = a + j,
           else
               res = 0;
           endif
       endfunction
upssss.... line 4 "j = test(a)" must be "j = test(a-1)"... it was the error of my code... :-* sorry and thanks for all.
    Regards,
    Pedro
------------------------------------------------------- SF.Net email is sponsored by: Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php _______________________________________________ Octave-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: [OctDev] Suport octave rescursive function?

William Poetra Yoga H
In reply to this post by Pedro Antonio Fructuoso Merino
--- Pedro Antonio Fructuoso Merino <[hidden email]> wrote:

> Hi all,
>     Suport octave rescursive function? In this case, how can I implement
> it? I'm trying something like that:
>         function res = test(a)
>             if (a>0)
>             j = test(a)
>                 res = a + j,
>             else
>                 res = 0;
>             endif
>         endfunction
>     but it's fauls...
>        Pedro
>

I think there's a bug in your function: if a is positive, then the function
"test" will get called again and again until you reach max_recursion_depth,
which is 256 by default.


William Poetra Yoga Hadisoeseno


       
               
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev