A few days ago, I ran across the following code snippet: From a developer’s point of view, this code is fine: it stated that a required argument is missing. However, from a user point of view, the message does not make any sense. Sure, the message tells the user that a required parameter is missing, […]
February 16, 2011
The Problem I want to remove all duplicates within a list The Solutions There are at least two solutions to this problem. The first employs the lsort -unique command and the second uses the lrmdups command from the Tclx package. 56 % package require Tclx 8.4 57 % lsort {1 3 1 2 2} 1 […]
February 15, 2011
The Problem I want to merge two lists, and eliminate duplicates. The Solution Use the union command from the Tclx package. 49 % package require Tclx 8.4 50 % set list1 {Peter Paul Marry} Peter Paul Marry 51 % set list2 {Paul John Ringo George} Paul John Ringo George 52 % union $list1 $list2 George […]
February 15, 2011
The Problem I want to compare two lists for equality, but disregard the order. For example: {a b c} and {b a c} are equal, but {a b c} {a b c d} are not. The Solutions There are several solutions to this problem. The first is to first sort the two lists, then compare […]
February 22, 2011
0