Browsing All Posts published on »February, 2011«

Error Messages Are for the Users

February 22, 2011

0

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, […]

How to Remove Duplicates in a Tcl List

February 16, 2011

2

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

How to Merge Tcl Lists and Eliminate Duplicates

February 15, 2011

2

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

How to Compare Two Unordered Tcl Lists

February 15, 2011

3

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

Follow

Get every new post delivered to your Inbox.

Join 34 other followers