Re: Recursive generators and backtracking search

2005-10-31 Thread Tim Peters
[Talin] > I've been using generators to implement backtracking search for a while > now. Unfortunately, my code is large and complex enough (doing > unification on math expressions) that its hard to post a simple > example. So I decided to look for a simpler problem that could be used > to demonstr

Re: Recursive generators and backtracking search

2005-10-30 Thread Talin
Alex Martelli wrote: > for x in whatever_other_iterable: yield x > > into (say) > > yield from whatever_other_iterable > > is minute and not worth changing the syntax (even though something like > 'yield from' would mean no keywords would need to be added). I agree that the improvement is minor,

Re: Recursive generators and backtracking search

2005-10-30 Thread Diez B. Roggisch
>>for pos in qsearch( pos ): >> yield pos > Um - do you really want to reuse the variable pos here? Yeah, it > works, but this strikes me as very confusing. I'm not sure that it > might not be implementation dependent. Certainly not. pos is - and that

Re: Recursive generators and backtracking search

2005-10-29 Thread George Sakkis
"Talin" <[EMAIL PROTECTED]> wrote: > I've been using generators to implement backtracking search for a while > now. Unfortunately, my code is large and complex enough (doing > unification on math expressions) that its hard to post a simple > example. So I decided to look for a simpler problem that

Re: Recursive generators and backtracking search

2005-10-29 Thread Mike Meyer
"Talin" <[EMAIL PROTECTED]> writes: > As an alternative, I'd like to present the following implementation. If > you compare this one with the one in lib/test/test_generator.py you > will agree (I hope) that by using recursive generators to implement > backtracking, the resulting code is a little mo

Re: Recursive generators and backtracking search

2005-10-29 Thread Alex Martelli
Talin <[EMAIL PROTECTED]> wrote: > even simpler - for examle, the idea of being able to return the output > of one generator directly from another instead of having to iterate > through all of the results and then re-yield them has already been > discussed in this forum. I missed those discussion

Recursive generators and backtracking search

2005-10-29 Thread Talin
I've been using generators to implement backtracking search for a while now. Unfortunately, my code is large and complex enough (doing unification on math expressions) that its hard to post a simple example. So I decided to look for a simpler problem that could be used to demonstrate the technique