For some bizarre reason, I am struggling to get my head around iterators/generators as used in Python (I write/use them with no problem in C++ – but somehow I can’t seem to grok how to write one using Python).
I have a mathematical function of the form:
f(a,b) = ( v1(a) - v1(b) ) / ( v2(a) - v2(b) )
Where v1 and v2 are equal length 1D vectors.
I want to write a function (actually, a generator), that generates the output of f() as defined above.
Can anyone help?
[[Edit]]
My notation may have been confusing. I hope to clarify that. The function described above return a set of values. With the argument b taking on values, in the interval (a,b]
So for example if we call f(1,5), the function will return the following values (not functions -in case my clarification below causes further confusion):
f(1,1)
f(1,2)
f(1,3)
f(1,4)
f(1,5)
You can use generator expression:
Or a generator function