combinations of variable length nested lists

Joseph A. Knapka jknapka at earthlink.net
Tue Aug 7 23:42:14 CEST 2001


Alex Martelli wrote:
> 
> "Mark Robinson" <m.1.robinson at herts.ac.uk> wrote in message
> news:3B7023A4.6020408 at herts.ac.uk...
> >
> > Joseph A. Knapka wrote:
> >
> > > PEP proposal: add a backtracking Horn-clause resolution
> > > engine to Python!
> > >
> > >  :-)
> > >
> > > This problem is a two-liner in Prolog:
> > >
> > > one_of_each([],[]).
> > > one_of_each([H|T],[H1|Ts]) :- member(H1,H), one_of_each(T,Ts).
>     ...
> > backtracking Horn-clause resolution engine, that can't be real
> > terminology, I am sure you just plagerised Elmer Fudge :)
> 
> The terminology is right, but the Prolog example he gives looks
> just like a transliteration of a ML or Haskell program and uses no
> backtracking that I can see.

Yet it's there. member/2 is nondeterministic, so the code
above will find every solution, if invoked via findall or
within a failure loop.

I don't know ML or Haskell (yet :-)

-- Joe Knapka
"You know how many remote castles there are along the gorges? You
 can't MOVE for remote castles!" -- Lu Tze re. Uberwald
// Linux MM Documentation in progress:
// http://home.earthlink.net/~jknapka/linux-mm/vmoutline.html
2nd Lbl A + 1 = 2nd Pause 2nd Prt GTO 2 R/S



More information about the Python-list mailing list