
11 Jul
2008
11 Jul
'08
3:32 p.m.
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.