Return index of for loop
- Subject: Return index of for loop
- From: Barton Willis
- Date: Wed, 26 Nov 2008 21:06:04 -0600
Try something like this:
f(n0,d):=block([ni : n0,k : 1],
while (ni : doubling_map(ni,d)) # n0 and k < 100 do (
k : k + 1),
if k = 100 then 0 else k)$
Barton
-----maxima-bounces at math.utexas.edu wrote: -----
>Can?it?be?done?better??
>
>/*?this?second?function?works?*/
>GiveP(n0,d):=block(
>[ni:n0,i:0],
>block(
>???loop,
>???ni:doubling_map(ni,d),
>???i:i+1,
>???if?i<100?and?not?(n0=ni)?then?go(loop)
>),
>if?(n0=ni)
>???? then?i
>???? else?0