Recursion

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

Hello Anyone,

constant stuff={"oranges","apples","bananas"}
 
 -- this is iteration
 
 procedure hello(object stuff)
   for x=1 to length(stuff)  do
        puts(1,stuff[x]&"\n")
   end for
 end procedure
 
 hello(stuff)
 
 --this is recursion
 
 procedure hello2(integer x)
    if  x>length(stuff) then
    else
      puts(1, stuff[x]   &"\n")
       hello2(x+1)
    end if
 end procedure

hello2(1)


Is this correct?

I notice that recursion uses more code.

Don Cole

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

Search



Quick Links

User menu

Not signed in.

Misc Menu