[Haskell-beginners] Using findIndex and then splitAt in Data.List

Geoffrey Bays charioteer7 at gmail.com
Sat Feb 28 15:02:27 UTC 2015


Michael:
Thanks, split on would work nicely.

I probably should have backed up in my reasoning process to say that my
real task is to replace a data item in a list with another altered data
item in the same position, or rather in FP, create a new list with the
altered item in the same place. And I need a predicate to find the name of
the item I want to replace.
Any thoughts?

Thanks,
Geoffrey
On Feb 28, 2015 9:08 AM, "Michael Orlitzky" <michael at orlitzky.com> wrote:

> On 02/27/2015 03:51 PM, Geoffrey Bays wrote:
> > Hi.
> > An elementary question here about two functions in Data.List:
> >  how to use a value from findIndex which returns a Maybe Int,
> > and then use that result in splitAt which takes a regular Int?
>
> Once you understand why you can't feed a (Maybe Int) to a function that
> takes an Int, throw it all away and use `splitOn` from the "split"
> package instead =)
>
> https://hackage.haskell.org/package/split-0.2.2/docs/Data-List-Split.html
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150228/9b930a59/attachment.html>


More information about the Beginners mailing list