TIP: | 334 |
Title: | Make 'lrepeat' Accept Zero as a Count |
Version: | $Revision: 1.2 $ |
Author: | Michael Thomas Greer <michael dot thomas dot greer at verizon dot net> |
State: | Withdrawn |
Type: | Project |
Tcl-Version: | 8.6 |
Vote: | Pending |
Created: | Monday, 13 October 2008 |
Keywords: | empty list |
Following on from TIP #323, the lrepeat command should also act gracefully when a repeat count of zero is used, as an empty list is still a valid list.
A list of zero items is a valid, empty list. In my own experience (I cannot speak for others'), generating a list of N identical elements is more often an algorithmic expression than a literal shorthand, and often enough an empty list is the correct result. All other core list commands properly handle empty lists; but lrepeat complains when given a count of zero repetitions, requiring additional code to handle this (doubly) exceptional condition.
The lrepeat command should be changed so that when it's first, count, argument is zero, it returns an empty list.
This document has been placed in the public domain.
[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]
TIP AutoGenerator - written by Donal K. Fellows