[Haskell-cafe] Newbie: Appending arrays?
Dan Weston
westondan at imageworks.com
Fri Jul 11 15:32:29 EDT 2008
Dmitri O.Kondratiev wrote:
> I need extendable array to store and count unique vectors. I have a file
> containing vectors presented as strings like:
> 10, 6, 80, 25, 6, 7
> 1, 2, 15, 17, 33, 22
> 21, 34, 56, 78, 91, 2
> ...
> (BTW, what is the best library function to use to convert string of
> digits into a list or array?)
If you don't need to do error checking on the input syntax, the easiest
(and arguably fastest) method is just read:
Prelude> let x = "10, 6, 80, 25, 6, 7"
Prelude> read ("[" ++ x ++ "]") :: [Int]
[10,6,80,25,6,7]
For error checking, you can use reads.
More information about the Haskell-Cafe
mailing list