Re: Recursion question?

new topic     » goto parent     » topic index » view thread      » older message » newer message

At 03:16 AM 14/12/00 -0500, you wrote:
>G'day all
>
>When a recusive function is used in Euphoria, are all the internal
>variables (including anything passed into the function) put in a stack of
>some kind? Ferinstance:
>
><NONSENSE CODE>
>function myfunc(sequence bigseq)
>   define another_bigseq
>   define other variables
>   do stuff to bigseq and another_bigseq
>   if somecondition
>      return(myfunc(another_bigseq))
>   else
>      return(another_bigseq)
>   end if
>end function
></NONSENSE CODE>
>
>Do all the intermediate "values" of each iteration of the function
>(including the big sequences) get pushed onto a stack? Or do I have that
>wrong?
>
>TIA
>
>Regards
>Tony
>
>


Yes.
Private variables are the property of each instance of
a function and stay in memory until the termination of
that instance. (cool huh?;)


This recursive function returns a list of the full paths to all
files in the directory passed and its subdirectories.


include file.e

function all_files(sequence path)
    -- no trailing '\' unless root dir i.e. c:\
    sequence d,list
    list={}
    d=dir(path)
    for x=1 to length(d) do
        if find('d',d[x][2]) then
            if d[x][1][1]!='.' then
                list=list&all_files(path&'\\'&d[x][1])
            end if
        else
            list=append(list,path&'\\'&d[x][1])
        end if
    end for
    return list
end function

Graeme Burke







----------------------------------------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu