Re: scientific.e
- Posted by Jason Gade <jaygade at ?ahoo.?om> May 22, 2008
- 718 views
Matt Lewis wrote: > > Shawn Pringle wrote: > > > > Matt Lewis and Jason Gade: > > > > I don't think it is clear what is going on > > to everyone here. > > The scientific_to_float64 probably expects a > > string of the form (+-)d\.d\+e(+-)dd. > > > I suggest you use a type for your function > > for the sake of illistration let us suppose > > there is a regex.e in the archive and a > > regex_match that does what perl's // operator > > does. Then the following is what you > > could use as a type. > > Yes, I understood what you were saying. > > > include regex.e > > type scientific_string( sequence s ) > > return regex_match( s, "(+-)\d\.\d\+e(+-)\d\d" ) > > end type > > I think a correct regex would be (including capturing all of the interesting > substrings): > > "(-?)(\\d+)(?:\\.(\\d+))?[eE][+\\-]?(\\d+)" > > Matt Sorry, I /hadn't/ understood. My reading comprehension skills seem to be lacking a little lately. My apologies. As Matt pointed out in another post, this behavior is documented and I missed it. The other numbers I passed the function were in the form "x.xxxxxxxxxxxxxxx" without an 'e' and those were parsed just fine. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.