[Haskell-beginners] Again on list manipulations

Alex Rozenshteyn rpglover64 at gmail.com
Fri Sep 10 13:55:17 EDT 2010


You're right, I meant (!!).  I've been playing with Array values recently,
and (!) is used there.

As has already been stated, genericIndex in the Data.List module will help
with the Integer problem, as will fromInteger.

As has also already been mentioned, lists + indexing = slow.  If you care
about efficiency, and you need indexing, you might want to look into
Data.Array.IArray if you have fixed bounds or Data.Sequence if you don't.

On Fri, Sep 10, 2010 at 11:12 AM, Lorenzo Isella
<lorenzo.isella at gmail.com>wrote:

> On 09/10/2010 05:03 PM, Alex Rozenshteyn wrote:
>
>  alternatively (and more cleanly),
>>  > results = map (ml !) sel
>>
>
> Thanks Alex. I am left with this problem only: the entries of sel are (in
> my code) Integer rather than Int so...I get an error message when compiling
> sine "!!" (I believe you left out a "!") expects an Int instead of an
> Integer.
> Any idea about how to fix this without converting sel from Integer to Int?
> Many thanks
>
> Lorenzo
>



-- 
          Alex R
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100910/64596012/attachment.html


More information about the Beginners mailing list