1. Problem Solved: (was: Newcomer with a problem)

Mutal recursion is possible with Euphoria in the most current version (Alpha
2)
You can get it from RDS' site.

How ?
Well, with routine id's.

Example:

procedure mutal_A (integer id, sequence arg)
    puts (1,"Calling procedure:")
    print (1, id)
    puts (1,"With the arguments:\n")
    print (1,arg)

    -- Look this up!
    call_proc (id, arg)
end procedure

procedure mutal_B (integer id, sequence arg)
    puts (1,"Calling procedure:")
    print (1, id)
    puts (1,"With the arguments:\n")
    print (1,arg)

    -- Look this up!
    call_proc (id, arg)
end procedure

-- Now let's use these weird looking routines..
integer a,b
a = routine_id ("Mutal_A")
b = routine_id ("Mutal_B")

call_proc (a, {b,{a,{b,{ } } } })

-- We now called routine a, that called routine b, that called routine a,
that called routine b.


Here's who wrote what so we can all look it up...

>At 01:50 25/01/98 +0000, David B. Williams wrote
>
>>Hello, everyone.  I'm new to Euphoria, and have been having a problem
>>that I can't seem to find the answer to in the documentation.  It's
>>probably there, I'm just horrible at finding things like that.
>>
>>I'm wondering about function and procedure declaration.  Currently,
>>I've got a function and a procedure.  They both call the other at one
>>point in their block, but because one appears before the other, the
>>interpreter says the second one is undefined (and therefore will not
>>continue running the program).
>>
>
>Unfortunately mutual recursion is not allowed in euphoria.
>A routine may call itself but not another routine that calls it.
>
>Graeme.
>

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu