|
|
|
|
|
by kamray23
1834 days ago
|
|
True, it is computationally worse, though it's O(nm) so applying m at compile time to form a practical use as I used it will turn it into to O(n) in practice. But that much is immediately obvious since it's mapping a filter, that is, has a loop within a loop. I did consider the second one to also take quadratic time though. I forgot that in python getting list elements by index is O(1) instead of O(n) which is what I'm personally used to with lists. It's also true that you can replace the filter with [ v | v <- l, v `mod` m == x ]
but that's not as much fun as(x ==) . (`mod` m) I just love how it looks and it doesn't personally seem any less clear to me, maybe a bit more verbose. |
|
Have you considered that maybe this is a sign you're too deep into using impractical programming languages?
Cleanness for immutable data structures aside, linked list are a very poor way to store data given the way computer architectures are designed.