Code: Select all
f(iter, p)
{
if (iter == null)
{
();
}
else
{
f(iter++, {iter#p;});
}
}
Code: Select all
f(iter, p)
{
if (iter == null)
{
();
}
else
{
f(iter, {iter++#p;});
}
}
Code: Select all
f(iter, p)
{
if (iter == null)
{
();
}
else
{
f(iter++, {iter#p;});
}
}
Code: Select all
f(iter, p)
{
if (iter == null)
{
();
}
else
{
f(iter, {iter++#p;});
}
}
Yeah sorry, I should've mentioned that.quantus wrote:What is iter? I'll assume it's some class that implements an iterator...
Is this true? Did you try it? I would think it had to evaluate the {} before making the next function call, which means that iter is getting incremented. Also, I was wrong in saying that f(++iter,{iter#p}) is kinda the same as f(iter,{iter++#p}) because the ++iter means that iter gets incremented before the {} part which would skip the first element in iter. By using {iter++#p}, you put the increment after the calculation, but before the actual function call.Peijen wrote:The second code doesn't work because {iter++#p} does not get evaluated until iter==null which never happends.
Code: Select all
f(iter, p)
{
if (iter == null)
{
();
}
else
{
k = iter++#p;
f(iter, k);
\\ or you can do the following with the same effect.
\\ k = iter#p;
\\ f(++iter, k);
}
}