[Haskell-beginners] reorganizing lists
Bryce Verdier
bryceverdier at gmail.com
Mon Jan 28 20:11:48 CET 2013
So I have a text full of x and y coordinates in the for x_y new line
delimited. Here is the first 3 lines:
68_1
153_16099247764943158
153_775041589
I'm massaging the data to run a liner regression on it. At the moment
the program I'm writing looks like this (still a work in progress...):
module Main where
import qualified Data.Text as T
import qualified Data.Text.IO as TI
import Numeric.GSL.Fitting.Linear
import Data.Packed.Vector
buildList :: IO [[T.Text]]
buildList = TI.readFile "lin_reg_data.txt" >>= return . map (T.split
(=='_')) . T.lines
--main :: IO ()
--main = do
-- values <- buildList
-- let heads = fromList $ map (\x -> read (T.unpack . head $ x)::
Double) values
-- let lasts = fromList $ map (\x -> read (T.unpack . last $ x)::
Double) values
-- print linear heads lasts
I'm just trying to find a way to not iterate over "vaues" twice as that
seems like a waste of computing time to me. Of course any advice on this
would be appreciated.
Bryce
On 01/28/2013 10:42 AM, Ozgur Akgun wrote:
> Hi,
>
> On 28 January 2013 18:37, Bryce Verdier <bryceverdier at gmail.com
> <mailto:bryceverdier at gmail.com>> wrote:
>
> I know I can do this with calling 2 maps on the container, but I
> would also like to do this in one iteration.
>
>
> As a learning experience, may I suggest you post the code you would
> have written with two maps? Then we can try and improve on that to
> have only one map.
>
> Best,
>
>
> --
> Ozgur Akgun
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130128/b69ace12/attachment.htm>
More information about the Beginners
mailing list