Anthony Borla writes: > Greetings, >
> Firstly, I'd really like to avoid the 'Filter' call. The reason I'm using it > is that extraneous carriage return [ASCII 13] characters appear in some > natively [Win32] created text files; this removes them [if present] and has > the advanatge of being reasonably platform independant [i.e. same code works > untouched under Linux where this problem does not exist]. Since the > extraneous character appears at the end of each line [thus the last element > in the character / code list], I was wondering whether it was possible to > remove this character via pattern matching without the need for any > additional processing ? > > My intuition tells me 'no'; because: > > * Pattern matching does not work like regexs > > * The item to be removed is in the list tail, and it is not > possible to specify this via pattern matching > > Am I correct in making these assumptions, or have I missed something ? > You are correct, but have you tried the Regex module? It would be more robust to use regex to extract the numbers from each line. > Secondly, the file data are integer strings e.g. > > 12 > 26 > 1254 > ... > > but will be processed as floats in the program, hence the type conversions. > I initially made use of 'String.toFloat' to effect the conversions but found > that the required conversions were not being carried out [that is, no '.0' > was being appended to each integer value] ! Experimentation showed that it > was first necessary to convert each string to integer type, then convert > each integer to float type in order to obtain valid floating point values. > > My question here is: is this two-step conversion necessary to obtain valid > floating point values from integer string data ? > Yes, I think so. String.tofloat insists that the string is in Oz concrete syntax, which seems to mean that it should have an explicit decimal point. You could read them first into a list of integers then map string.toFloat over them at the end, or write a helper function that combines the two calls. > Any help appreciated. > > Cheers, > > Anthony Borla > > P.S. > > Is there an online search facility available for the Mozart mailing list > archives, or is it necessary to download the gzip files and perform local > searches of archive contents ? Yes, see the google search half way down this page: http://www.mozart-oz.org/lists/ cheers k _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
