[Haskell-beginners] nub... almost

Alexander Dunlap alexander.dunlap at gmail.com
Sat Jun 4 20:57:17 CEST 2011


Why? According to Data.Set documentation, "If the set already contains
an element equal to the given value, it is replaced with the new
value." So as long as you insert into the set starting from the front
of the list and proceeding towards the back, you will end up with the
last element prevailing.

Alex

On 4 June 2011 10:03, Benjamin Edwards <edwards.benj at gmail.com> wrote:
> nub = toList . foldl (flip insert) empty
>
> But it's crap because it doesn't respect the ordering on the list.
>
> On 4 Jun 2011 17:53, "Christopher Howard"
> <christopher.howard at frigidcode.com> wrote:
>
> On 06/04/2011 12:20 AM, Iustin Pop wrote:
>> On Fri, Jun 03, 2011 at 11:49:01PM -0800, Christopher Ho...
>
> @iustin: Thanks, that should work well enough.
>
> @Edwards: I'm not familiar with Data.Set, so I do not understand your
> solution.
>
> --
> frigidcode.com
> theologia.indicium.us
>
> _______________________________________________
>
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>



More information about the Beginners mailing list