File reading question
Hal Daume III
hdaume at ISI.EDU
Fri Sep 12 10:50:20 EDT 2003
Arrays or lists?
Lists is easier.
(transpose . map (map read . words) . lines) `liftM` readFile "file"
should do it (untested code, though).
On Fri, 12 Sep 2003, Gordon James Miller wrote:
> Hello all,
>
> I believe I have a mental block on some issues related to IO and would
> really appreciate some help on this. I have a text file that contains
> two columns of numbers, basically X and Y values. I need a function (or
> set of functions) that reads this file and returns two arrays, one of
> the X values and one of the Y. A sample data file might look like.
>
> 10.0 20.0
> 20.0 40.0
> 30.0 60.0
> 40.0 80.0
>
> Reading in this file should return two arrays [10.0, 20.0, 30.0, 40.0]
> and [20.0, 40.0, 60.0, 80.0].
>
> Thanks for any help on this, I just don't seem to get IO in Haskell
> without reassignments.
>
>
>
> Gordon James Miller Promisemark, Inc. Senior Computer Scientist
> gmiller at promisemark.com (571)330-9012 The box said "Requires Windows 95
> or better." So I installed LINUX
>
> _______________________________________________
> Haskell mailing list
> Haskell at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell
>
--
Hal Daume III | hdaume at isi.edu
"Arrest this man, he talks in maths." | www.isi.edu/~hdaume
More information about the Haskell
mailing list