Re: Strings to Integers
- To: mathgroup at smc.vnet.net
- Subject: [mg67607] Re: Strings to Integers
- From: "Norbert Marxer" <marxer at mec.li>
- Date: Sun, 2 Jul 2006 06:27:13 -0400 (EDT)
- References: <e85f03$k94$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello
Try
Map[
(Function[t, 60t[[1]] + t[[2]]][ToExpression@StringSplit[#,
":"]])&,
{"12:33", "120:03", "343:59", "1:00"}]
which will give you
{753, 7203, 20639, 60}
The following steps are performed:
StringSplit splits the time string in a list of strings for minutes and
seconds.
ToExpression converts this to a list of Integers for minutes and
seconds.
The pure function Function[...] gives this time in seconds (alone).
Map applies these steps to a list of time strings.
I'm sure, there would be many other (smarter?) ways to do the same.
Best Regards
Norbert Marxer
www.mec.li