r/functionalprogramming • u/n_creep • May 02 '24
Haskell When Are Functions Lazy Enough for Lists
https://blog.daniel-beskin.com/2024-05-02-lazy-enough
14
Upvotes
r/functionalprogramming • u/n_creep • May 02 '24
5
u/Economy_Bedroom3902 May 02 '24
Pretty interesting. I don't think about infinite data structures too often, although most of the same principles apply for writing functions to deal with very very very large datasets :P
[edit] an interesting exception would be length(). A lot of languages store length as a counter that increments and decrements as data is added or removed from the data set, rather than an actual scan of every piece of data within the dataset. So we can usually still have a length() even with astronomically large datasets, there's just a tradeoff of a small chance of inaccuracy vs very fast performance instead of very slow performance.
3
u/RedEyed__ May 03 '24
This is part of my daily work, dealing with very large datasets, where some data maybe corrupted. In python I just define generator, which skips corrupted data. So I had to deal with every function which expects
len()available.