Dérécursivité

Bonjour,
je dipose du code ci-dessous sous Scilab récursif en la variable k de la fonction delta et donc peu efficace. Je ne sais pas comment le transformer en itératif. C'est une façon de penser dont je n'ai pas trop l'habitude. Pouvez-vous m'aider ? Idem pour la fonction alpha.
Merci.
function[res]=delta(y,x,k,p,N,L,pi)
    Eu=E(p,N)
    P=Pa(N)
    if k==1 then 
        z=y(1,:)
        res= pi(x+1)*Eu(1+z(1)+z(2)*(N+1),x+1)
    else
    for i=0:N
       u(i+1)=delta(y,i,k-1,p,N,L,pi)*P(i+1,x+1)
            end
     
    w=y(k,:)
    res=max(u)*Eu(1+w(1)+w(2)*(N+1),x+1)
    end
  endfunction

function[res]=alpha(y,x,k,p,N,L,pi)
    Eu=E(p,N)
    P=Pa(N)
    res=0
    if k==1 then
        z=y(1,:)
        res=Eu(1+z(1)+z(2)*(N+1),x+1)*pi(x+1)
    else
        w=y(k,:)
        for i=0:N
            res=res+alpha(y,i,k-1,p,N,L,pi)*P(i+1,x+1)*Eu(1+w(1)+w(2)*(N+1),x+1)
        end
    end
endfunction
Connectez-vous ou Inscrivez-vous pour répondre.