Version 8 of Things British

Updated 2002-01-11 19:21:35

Richard Suchenwirth - This is not another OO game, just some Tcl notes for peculiarities of the United Kingdom. Tcl/Tk code to draw the Union Jack on a canvas can be had at Describing and rendering flags in Tcl.

Non-decimal money: Kevin Kenny (2 November 2000) At least we seldom have to deal with mixed radix currencies any more; dealing with pounds-shillings-pence was quite an �sd trip.

 �2 16s 2 3/4d

was read as "two pounds, sixteen shillings tuppence ha'penny farthing").

Steve Blinkhorn: Of no programming relevance whatsoever - no it wasn't. "Two pounds sixteen and tuppence three-farthings" was what we used to say. Or often, for sums of money that amounted to less than five pounds (books were a typical example), only shillings and pence were counted: �1/15/- (the dash meant no pence) was often rendered as 35/-, "thirty-five shillings" or more colloquially "thirty-five bob". �1/19/6 ("one pound nineteen and six") would be "thirty-nine and six", and �1/19/11 "thirty-nine and eleven", allegedly popular price points because they forced sales assistants to to work the till ("cash register") as a theft preventative measure.

There was, at the time of the introduction of decimal currency in the UK in 1971, a wonderfully mock-erudite study of the sociological and social anthropological study of the retiring currency system, pointing out that pence, shillings, pounds and guineas (a guinea was �1/1/-, still used I believe as the unit of bidding in racehorse auctions) were the units of choice of workmen, merchants, professionals and aristocrats respectively.

RS: Except for fractions of old pence, the following converts decimal GBP amounts to L-s-d, and Unicoded:

 proc dec2trad {amount {slash " "}} {
        set L [expr int($amount)]
        set s [expr int(($amount-$L)*20)]
        set d [expr int(($amount-$L-$s/20.)*240+0.5)]
        set res ""
        if {$slash==" "} {
                if $L {append res "\u20A4$L"}
                if $s {append res " ${s}s"}
                if $d {append res " ${d}d"}
        } else {
                if $L {append res "\u20A4$L/"}
                if $s {append res $s} else {append res -}
                if $d {append res /$d} else {append res /-}
        set res
 dec2trad 10.01 /
 dec2trad .10 /

UK phone-book sorting order: Donal Fellows wrote in comp.lang.tcl: Indeed, even for strings there are many different ordering relations. Tcl supports two directly in [lsort]: ASCII and Dictionary. There are others though; dictionary ordering should be dependent on locale, and there are also other orderings like phone-book ordering (in the UK, MacDonald should come between McArthur and McEwan in phone number listings, and all should precede Mabbs.)

 proc {x y} {
        foreach i {x y} {
            regsub {Ma?c ?([A-Z])} [set  $i] {M_\1} $i
        string compare $x $y
 lsort -command {MacDonald McArthur McEwan Lyttle Mabbs Jones}
 Jones Lyttle McArthur MacDonald McEwan Mabbs

KBK (14 February 2001) -- [lsort -command] is a pig from the performance standpoint. Much faster, although treble the memory consumption, is:

 proc { list } {
    foreach name $list {
        regsub {Ma?c ?([A-Z])} $name {M_\1} key
        lappend list2 [list $key $name]
    foreach pair [lsort -index 0 -ascii $list2] {
        lappend list3 [lindex $pair 1]
    return $list3
 } {MacDonald McArthur McEwan Lyttle Mabbs Jones}

For virtually all applications, this technique of ``sort a list of pairs'' should be preferred to [lsort -command].

There's a benchmark of the two versions of the command over on the lsort page.

English plurals - English number reader

Things Japanese - Arts and crafts of Tcl-Tk programming

I mark-up printouts of code with a 1939 Conway Stewart 475. Does that count? -pse