FoldL/R Reducing List

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

FoldL/R Reducing List

Waaaggh
Hi.how can i reduce list with foldl.r ?

np (1,1,1,2,3,3,4,5,5) -> (1,2,3,4,5) ???
Azz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090622/4c62f380/attachment.html
Reply | Threaded
Open this post in threaded view
|

FoldL/R Reducing List

Daniel Fischer-4
Am Montag 22 Juni 2009 13:10:08 schrieb Waaaggh:
> Hi.how can i reduce list with foldl.r ?
>
> np (1,1,1,2,3,3,4,5,5) -> (1,2,3,4,5) ???
> Azz.

First, these are tuples, not lists.
Second, what are you trying to do?
Implement nub via fold(l)r?
Is http://www.haskell.org/haskellwiki/Homework_help relevant to your request?
Reply | Threaded
Open this post in threaded view
|

FoldL/R Reducing List

Waaaggh
i am trying to implement remowal of repetting elements from lists with foldeg.
[1,1,1,2] -> [1,2]
[1,1,2,2,3,1,1,1] -> [1,2,3,1]


2009/6/22 Daniel Fischer <[hidden email]>

> Am Montag 22 Juni 2009 13:10:08 schrieb Waaaggh:
> > Hi.how can i reduce list with foldl.r ?
> >
> > np (1,1,1,2,3,3,4,5,5) -> (1,2,3,4,5) ???
> > Azz.
>
> First, these are tuples, not lists.
> Second, what are you trying to do?
> Implement nub via fold(l)r?
> Is http://www.haskell.org/haskellwiki/Homework_help relevant to your
> request?
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090622/15c8a123/attachment.html
Reply | Threaded
Open this post in threaded view
|

FoldL/R Reducing List

Chaddaï Fouché
On Mon, Jun 22, 2009 at 2:12 PM, Waaaggh<[hidden email]> wrote:
> i am trying to implement remowal of repetting elements from lists with fold
> eg. [1,1,1,2] -> [1,2]
> [1,1,2,2,3,1,1,1] -> [1,2,3,1]
>

It's pretty easy to do with foldr and a "variant" of cons (:), it's a
little bit more tricky to do it with proper lazyness but nothing
serious.

--
Jeda?