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]]

(we do not assume the given set has order, so the result is not
ordered.)

Perl code and Python code will be posted in 2 days.

This is brought to you by the perl-python community. To subscribe, see
http://xahlee.org/perl-python/python.html

 Xah
 [EMAIL PROTECTED]
 http://xahlee.org/PageTwo_dir/more.html

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to