Function within a function and recursion

Started by suicidal pencil, Tue 02/12/2008 01:42:57

Previous topic - Next topic

suicidal pencil

Two part question, all about functions.

part A) Can you have a recursive function (Have the function call itself)?

and

part B) Can you have a function call another function? (having 'function DoThis()' use 'function DoThat()', then continue on)?


RickJ

A) I believe so but care must be taken with the stack.  Perhaps some others here have something more specific.

B) Yes definitely!.

Khris

Yes, recursive functions are possible.

I'm curious, why didn't you just try it...?

suicidal pencil

I still don't know the full extent of what the scripting language can do, and I didn't think that it could.

Thanks for the answer. Knowing that I can do it will make life sooooo much easier for me.

Pumaman

Yes, however the script engine will not allow a call stack more than 50 functions deep, so if you wanted to do some kind of recursive sort requiring hundreds of nested function calls you would not be able to do so at present.

SMF spam blocked by CleanTalk