MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/shittyprogramming/comments/odhig9/haskells_lazy_evaluation_makes_for_very/
r/shittyprogramming • u/maweki • Jul 04 '21
5 comments sorted by
16
Lazily generate an infinite list of [true,false,true,false...] and then find the position of n?
8 u/MarcusTL12 Jul 04 '21 Yes 5 u/[deleted] Jul 04 '21 I don’t remember my Haskell, soDoes it work when n is negative? 5 u/brookllyn Jul 04 '21 No, negative indexes don't work on a list
8
Yes
5 u/[deleted] Jul 04 '21 I don’t remember my Haskell, soDoes it work when n is negative? 5 u/brookllyn Jul 04 '21 No, negative indexes don't work on a list
5
I don’t remember my Haskell, soDoes it work when n is negative?
5 u/brookllyn Jul 04 '21 No, negative indexes don't work on a list
No, negative indexes don't work on a list
11
This is slow af, should be
evenness = True : False : evenness
Your way has to traverse the entire list every 2 values because you used ++ to just join together a bunch of terminating lists
16
u/[deleted] Jul 04 '21
Lazily generate an infinite list of [true,false,true,false...] and then find the position of n?
11
u/ReveredOxygen Jul 04 '21
This is slow af, should be
Your way has to traverse the entire list every 2 values because you used ++ to just join together a bunch of terminating lists