mardi 14 juillet 2020

Julia Lang If Statement issue

I have been trying to run a code similar to the following but the evaluation hangs on and consumes all the pc memory.... What I'm doing wrong?

function db(v)
c=0;
r=0;
i=1;
while i<=lastindex(v)
    if v[i]==0
        c=c+1
    else
     r=r+1
    end
end
return c;
return r;
end

r=[1,0,4,5,0,0,7];

db(r) > hogs the memory an no result....

Aucun commentaire:

Enregistrer un commentaire