def execute (code) :<br>    p = 0<br>    while p < len(code) :<br>        func = code[p]<br>        p += 1<br>        newP = func(code,p)<br>        if newP != None :<br>            p = newP<br><br>I'm trying to work out what this does....<br>
<br>code is a list of function addresses and numbers<br>What on earth is funct(code,p) doing???<br><br>My understanding so far is...<br>set p to 0<br>while p is less than the number of elements in list code keep doing what follows...<br>
set func to the first element in the list<br>increment the list index p<br>?<br>if newP is not null then set the list index p to ?<br>Can someone please explain in english what ? is<br>Thank you in anticipation<br><br>BTW the link for this stuff is <br>


<p style="margin:0in;font-family:Verdana;font-size:20pt" lang="EN-GB"><a href="http://openbookproject.net/py4fun/forth/forth.html">http://openbookproject.net/py4fun/forth/forth.html</a></p>

to see the thing in action ie the download link is on the above page<br><br>Here's a listing of the output from this proc for the following forth input i.e. I put some print statements in<br>but have no idea how<br>newP set to func( [<function rPush at 0x0164F570>, 4] , 1 ) i.e.  2<br>
results in 2<br>and then<br>newP set to func( [<function rAdd at 0x0164F130>] , 1 ) i.e.  None<br>results in None<br>???<br><br><br>Forth> 5 4 + .<br><br>1st line of execute__________________<br>code =  [<function rPush at 0x0164F570>, 5]<br>
p =  0<br>1st line of while__________________<br>func = code[ 0 ] i.e.  <function rPush at 0x0164F570><br>incrementing p to  1<br>newP set to func( [<function rPush at 0x0164F570>, 5] , 1 ) i.e.  2<br>p = newP i.e.  2<br>
<br>1st line of execute__________________<br>code =  [<function rPush at 0x0164F570>, 4]<br>p =  0<br>1st line of while__________________<br>func = code[ 0 ] i.e.  <function rPush at 0x0164F570><br>incrementing p to  1<br>
newP set to func( [<function rPush at 0x0164F570>, 4] , 1 ) i.e.  2<br>p = newP i.e.  2<br><br>1st line of execute__________________<br>code =  [<function rAdd at 0x0164F130>]<br>p =  0<br>1st line of while__________________<br>
func = code[ 0 ] i.e.  <function rAdd at 0x0164F130><br>incrementing p to  1<br>newP set to func( [<function rAdd at 0x0164F130>] , 1 ) i.e.  None<br><br>1st line of execute__________________<br>code =  [<function rDot at 0x0164F430>]<br>
p =  0<br>1st line of while__________________<br>func = code[ 0 ] i.e.  <function rDot at 0x0164F430><br>incrementing p to  1<br>13<br>newP set to func( [<function rDot at 0x0164F430>] , 1 ) i.e.  5<br>None<br>
Forth> <br>