[Haskell-cafe] Simple list processing
Thomas M. DuBuisson
thomas.dubuisson at gmail.com
Wed Jun 11 16:46:23 EDT 2008
Why is there no mapAccumL' (strict)? Just a library deficiency that we
can remedy or am I missing something?
Don Stewart wrote:
> andrewcoppin:
> > OK, so this is a fairly basic question about list processing.
> >
> > Several times now, I have found myself wanting to process a list to
> > produce a new list. However, the way later elements are processed
> > depends on what the earlier elements are - in other words, this isn't a
> > simple "map".
> >
> > What is the best way to handle this?
> >
> > According to the theory, anything that consumes a list and produces a
> > value is some kind of fold. [Assuming it traverses the list in a
> > sensible order!] So it looks like you could implement this as a fold.
> > But should that be a LEFT-fold or a RIGHT-fold? (I always get confused
> > between the two!)
> >
>
> Sounds like a mapAccum, a combination of map and fold,
>
> http://haskell.org/ghc/docs/latest/html/libraries/base/Data-List.html#v%3AmapAccumL
>
> If you gave a concrete example it would be easier to diagnose.
>
> -- Don
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list