Please excuse the crudity / simplicity of this question, hbut I have never really got on too well with Do
structures - perhaps I don't use them enough - perhaps I avoid them!
How would I create a do loop that performs a given operation on each new value?
eg
val=10;
Log@val // N
a = 39 - %
b = % - Log@%
c = % - Log@%
d = % - Log@%
e = % - Log@%
ToExpression[CharacterRange["a", "e"]]
Of course it can be done with
f[0] = 10;
f[1] = N[f[0] - Log@f[0]]
f[n_] := f[n - 1] - Log[f[n - 1]]
f[5]
but I was wondering whether Do
could do the operation.
Do
loop, or to execute this list of operations? In general, this looks a lot like aFoldList
kind of construct. $\endgroup$Do
$\endgroup$f[0]=10.; Do[f[i]=f[i-1]-Log[f[i-1]],{i,n}]
$\endgroup$(tmp = 10; Do[tmp = N[tmp - Log[tmp]], {#}]; tmp) &
... $\endgroup$Do
structures $\endgroup$