4 ms·
Only if you have infinite memory. In theory there's no difference between folding left and folding right (if associative), in practice there is a right way and
by mantap 7y ago
Only if you have infinite memory. In theory there's no difference between folding left and folding right (if associative), in practice there is a right way and a wrong way.
- yakshaving_jgt 7y ago> In theory there's no difference between folding left and folding right There's no difference in practice either for a sufficiently small dataset. > in practice there is a right way and a wrong way Sure, but that's true of all technologies. Yes, Haskell can't help you escape the limitations of our world — or indeed our hardware — but it doesn't pretend to either.
- magicalhippo 7y ago> There's no difference in practice either for a sufficiently small dataset. As a non-Haskell user, just for reference what's "sufficiently small"?
- yakshaving_jgt 7y agoIt depends on your needs. This is neither constrained to Haskell specifically nor functional programming more generally. If you were building a website for your local Italian restaurant, what would your needs be? Do you need an ElasticSearch cluster to handle customer menu item queries? Do you need a database at all? In Haskell's case it's best to avoid lists entirely, as they're _usually_ not the optimal data structure. But best for whom? Does the beginner care that a set operation would be more effective than a list operation for their given use-case?
- magicalhippo 7y agoNot sure how that's an answer to my question? In my day job, I frequently generate records returned from a database along with local changes to be posted later, and say compute the sum of one of the columns. That sounded like something I'd use folding for, with my limited knowledge, so I was just curious at which point (order of magnitude) I'd have to worry about doing it this way or that. But if lists are not to be used, what should I use for the above? And will the data structure you propose be fine with either fold?
- yakshaving_jgt 7y agoAgain, it depends. A left fold might be fine (and likely will be). Lists might be fine (and likely are). I don't know anything about the size of your data, or about the business you're writing software to support (who knows, maybe you're writing a FPS game, or some real-time aviation software!). At this point (taking into account the extent of your knowledge as you yourself described it), my advice would be to just use basic folding and lists. At some point in the future, if you observe some performance issue in exactly that area, you might remember this and think "hmm, memory consumption is bit excessive here; maybe I'll try a foldr instead", or "finding the intersection of these two big lists is a little slow; maybe I'll convert them both to sets instead?"
- ukj 7y ago>There's no difference in practice either for a sufficiently small dataset. So what happens in practice with unfortunately large datasets? >Yes, Haskell can't help you escape the limitations of our world — or indeed our hardware — but it doesn't pretend to either Then what is Haskell's value-proposition when it comes to solving real-world problems?
- yakshaving_jgt 7y ago> So what happens in practice with unfortunately large datasets? You take a different approach. Haskell provides plenty of options. > Then what is Haskell's value-proposition when it comes to solving real-world problems? There are many. You can consult your favourite search engine to learn more.
- ukj 7y ago>You take a different approach. Haskell provides plenty of options. So do other languages. Why is Haskell special in this regard? >There are many. You can consult your favourite search engine to learn more. None that seem to address the problem of diminishing returns.
- yakshaving_jgt 7y ago> So do other languages. Why is Haskell special in this regard? I never suggested other programming languages don’t also have value. Again, if you want to educate yourself further on a specific technology’s benefits, I invite you to make use of a search engine instead of sea-lioning on a technical forum. > None that seem to address the problem of diminishing returns. That’s your opinion. Nobody is forcing you to like Haskell. You are free to just ignore it.