Re: [perl-python] generate all possible pairings

2005-03-01 Thread Xah Lee
Answer to the previous exercise. http://xahlee.org/perl-python/generate_pairings.html # perl sub genpair ($) { my $partiSet = $_[0]; my @result; for (my $head =0; $head <= ((scalar @$partiSet)-2); $head++ ) { for (my $tail = $head+1; $tail <= ((scalar @$partiSet)-1); $tail++ ) { foreac

Re: [perl-python] generate all possible pairings

2005-02-26 Thread Chris Mattern
Mike Meyer wrote: > "Xah Lee" <[EMAIL PROTECTED]> writes: > >> This is brought to you by the perl-python community. To subscribe, see >> http://xahlee.org/perl-python/python.html > > assert len(perl-python community) == 1 > >http://mail.python.org/mailman/listinfo/python-list

Re: [perl-python] generate all possible pairings

2005-02-26 Thread Mike Meyer
"Xah Lee" <[EMAIL PROTECTED]> writes: > This is brought to you by the perl-python community. To subscribe, see > http://xahlee.org/perl-python/python.html assert len(perl-python community) == 1 http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consulta

[perl-python] generate all possible pairings

2005-02-26 Thread Xah Lee
20050226 exercise: generate all possible pairings given a list that is a set partitioned into subsets, generate a list of all possible pairings of elements in any two subset. Example: genpair( [[9,1],[5],[2,8,7]] ); returns: [[5,8],[9,5],[1,5],[9,2],[9,7],[1,8],[1,7],[5,2],[1,2],[9,8],[5,7]]