[Richard Suchenwirth] 2004-06-10 - A challenge in [Tcl programs for beginners] made me rebake an earlier half-baked idea: the pattern of a data ''comb'' which returns some string depending on a numeric value and a specification, which gives the possible strings and the borderline values, e.g. (in Centigrades): {"bitter cold" -10 cold 10 fresh 15 nice 25 warm 30 hot} You can consider the even elements of this list as being the comb's tooth, and the even elements as the values to return. The code is of course pretty easy: proc comb {x spec} { foreach {value limit} $spec {if {$x<$limit} {return $value}} return $value } # Testing: % comb 11 {child 13 teen 19 adult} child % comb 15 {child 13 teen 19 adult} teen % comb 99 {child 13 teen 19 adult} adult ---- [Arts and crafts of Tcl-Tk programming]