Posted to tcl by aspect at Tue Jun 19 15:20:29 GMT 2012view raw

  1. proc case_map {from to input} {
  2. foreach op {toupper tolower totitle} {
  3. lappend map [string $op $from] [string $op $to]
  4. }
  5. string map $map $input
  6. }
  7.  
  8. puts [case_map poems poetry "Poems are poems are POEMS (but not pOEMS)"]
  9.