From 02e1ccb186a56d72a7366c104d3aded5bcc4c787 Mon Sep 17 00:00:00 2001 From: ccremers Date: Thu, 14 Oct 2004 20:09:11 +0000 Subject: [PATCH] - Tuple generator now works great. --- spdl/tuples.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/spdl/tuples.py b/spdl/tuples.py index 258c8c3..55b1872 100755 --- a/spdl/tuples.py +++ b/spdl/tuples.py @@ -22,7 +22,7 @@ import sys import string # Retrieve the tuple width -tuplesize = sys.argv[1] +tuplesize = int(sys.argv[1]) print tuplesize # Read stdin into list and count @@ -45,3 +45,21 @@ while loop: print list print len(list) +def tupleUnit (x): + print x + "\t", + +def tuplesPrint (l, n, r): + if r and (len(r) == n): + for x in r: + print x, + print "\t", + print + else: + if l and (n > 0): + # Larger size: we have options + # Option 1: include first + tuplesPrint (l[1:], n, r + [l[0]]) + # Option 2: exclude first + tuplesPrint (l[1:], n, r) + +tuplesPrint (list, tuplesize, [])