[Haskell-cafe] Made me smile

Dan Weston westondan at imageworks.com
Fri May 18 18:10:16 EDT 2007


How does the type of fromList get determined? And is Data.Set.toList the 
same as Data.Set.toAscList?

Dan Piponi wrote:
> If you allow me to play Devil's advocate for a moment...just don't let
> this guy ask you how long the Haskell version takes.
> 
> In fact, you can borrow a trick from the C++ version. Try this instead:
> 
>> import Data.Set
>> main = interact $ unlines . toList . fromList . words
> 
> Assuming Data.Set is implemented the way I think it is it should
> perform much better than the sort . nub version.
> -- 
> Dan
> 
> On 5/18/07, Andrew Coppin <andrewcoppin at btinternet.com> wrote:
>> OK, so I was hanging out on this newsgroup I often lurk. And we're
>> having a discussion. And I'm all like "Haskell is the greatest!" And
>> they're all like "nah, Haskell sux". And this one dude goes "hey, look
>> at this C++ code. How do you do that in Haskell?" And three other people
>> look at this C++ and can't figure out what the heck it even does. So
>> eventually he tells us what it does, and so I post some Haskell in a
>> reply. And the some other guy writes this...
>>
>> (OK, not much point to this email. But it seriously made me LOL IRL!)
>>
>>
>>
>>
>>
>> Invisible wrote:
>> >>>> int main()
>> >>>> {
>> >>>>     typedef std::istream_iterator<std::string> Is;
>> >>>>     typedef std::ostream_iterator<std::string> Os;
>> >>>>     std::set<std::string> t((Is(std::cin)), Is());
>> >>>>     std::copy(t.begin(), t.end(), Os(std::cout, "\n"));
>> >>>> }
>>
>> > OK then.
>> > main = interact $ unlines . sort . nub . words
>>
>> Pwned!
>>
>> -- 
>>   Darren New / San Diego, CA, USA (PST)
>>     His kernel fu is strong.
>>     He studied at the Shao Linux Temple.
>> _______________________________________________
>> Haskell-Cafe mailing list
>> Haskell-Cafe at haskell.org
>> http://www.haskell.org/mailman/listinfo/haskell-cafe
>>
> _______________________________________________
> 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