Programming challenge

Andy Bradford amb-plug at bradfords.org
Fri Sep 28 15:29:45 MDT 2007


Thus said "Sasha Pachev" on Thu, 27 Sep 2007 15:44:45 MDT:

> Given a  string that  could contain  arithmetic expressions,  with the
> addition  that numeric  constants  could be  potentially expressed  as
> times, e.g  1:36 for  96 seconds,  or 2:10:08 for  2 hours  10 minutes
> and  8 seconds,  also  decimal fractions  after  seconds are  allowed,
> e.g  3:45.6 or  3:40:50.67, replace  all  the time  values with  their
> equivalent number of seconds.

The following should be removed from my code snippet starting on line 14
(it was from an experiment I had in the code):

      if {[regexp {(\.\d+)} [lindex $s $x] m]} {
        set z [expr $z + 60 * [scan $m "%f"]]
      }

Andy
--
[-----------[system uptime]--------------------------------------------]
  3:29pm  up  6:24,  1 user,  load average: 1.00, 1.00, 1.00



More information about the PLUG mailing list