24 Sep 10:46
Re: export toDescList from Data.Map
From: Christian Maeder <Christian.Maeder <at> dfki.de>
Subject: Re: export toDescList from Data.Map
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2008-09-24 08:46:18 GMT
Subject: Re: export toDescList from Data.Map
Newsgroups: gmane.comp.lang.haskell.libraries
Date: 2008-09-24 08:46:18 GMT
Hallo Evan, If it is really such a performance difference the functions should be exported by all means. (Another work-around might by to inverse the order of the keys, but that'll be unnatural at least for Int keys.) Obviously, I rarely have 1 million elements in my maps. Evan Laforge wrote: >>> That's one of the things I was asking... how do you obtain toDescList >>> without foldlWithKey? And for me, since since the order of the keys >>> is important (say points in time), the order of the fold matters a >>> great deal. >> I thought of "reverse . toList". Maybe the folding functions are not >> needed at all (or only short cuts): > > Ah, well if I really didn't care about performance, then I wouldn't > use Map at all, just an unsorted [(k, v)]. But it's sort of awkward > for the GUI to freeze for a second (yes, it really does take that > long) while haskell reverses a 1 million element list just to get the > first 3 elements (and does so many times)... findMax (deleteFinMax) for the highest 3 elements would be faster then. >> foldlWithKey f z = foldl (\ b (k, v) -> f b k v) z . toList > > This is equivalent to reverse, isn't it? It also takes a second or so > (well, once I add a prime of course, without the prime it sends the > whole system into OOM molasses).(Continue reading)
RSS Feed