[Haskell-cafe] Newbie: Appending arrays?

Dmitri O.Kondratiev dokondr at gmail.com
Fri Jul 11 17:26:42 EDT 2008


Thanks for your help, guys!  I like simple solutions most of all  :)
 On Fri, Jul 11, 2008 at 9:44 PM, Reid Barton <rwbarton at math.harvard.edu>
wrote:

    This doesn't require any fancy data structures.
    Instead store this as a list of pairs [([10,6,80,25,6,7], 5), ...]
    and it'll be easy to write a recursive function that accepts a new
    vector and either increments the appropriate count or adds the new
    vector at the end with count 1.

On Fri, Jul 11, 2008 at 11:32 PM, Dan Weston <westondan at imageworks.com>
wrote:

> 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.
>
>


-- 
Dmitri O. Kondratiev
dokondr at gmail.com
http://www.geocities.com/dkondr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20080712/dd7cc4d9/attachment.htm


More information about the Haskell-Cafe mailing list