what do these mean

2012-05-20 Thread e-mail mgbg25171
There's a little forth program written in python here #http://openbookproject.net/py4fun/forth/forth.py I'm struggling to understand what these lines mean. def rJnz (cod,p) : return (cod[p],p+1)[ds.pop()] def rJz (cod,p) : return (p+1,cod[p])[ds.pop()==0] Specifically I'm stuck on what

what does newP = func(code,p) do?

2012-05-16 Thread e-mail mgbg25171
def execute (code) : p = 0 while p len(code) : func = code[p] p += 1 newP = func(code,p) if newP != None : p = newP I'm trying to work out what this does code is a list of function addresses and numbers What on earth is funct(code,p)

what does newP = func(code,p) do?

2012-05-16 Thread e-mail mgbg25171
It's been a long time since I did any Python and I've never done that In C I'm used to storing function ptrs and then having to use some other constructs to call them. To be able to store func and then use func to call itself like that threw me...it's very elegant. Thank you very much for your