foldl (flip ($)) 1 . take n . cycle $ [(*2), (+1)]
the epitome of Haskell's failure to go into mainstream. The whole logic is drawn into a symbolic soup where you forget what you wrote 5 minutes ago and you have to go back and remember what you did.
In parallel here is an implementation in Racket Scheme and how more readable it is:
(define (get-height n)
(if (= n 0)
1
(utopian-tree-iter 1 n 2)))
(define (utopian-tree-iter curr n height)
(cond ((equal? curr n) height)
((even? curr) (utopian-tree-iter (+ curr 1) n (times2 height)))
(else (utopian-tree-iter (+ curr 1) n (+ height 1) ))))
(define (times2 x) (* x 2))
Here functions have names and they are easier to understand.
Sometimes it pays to be a little bit more verbose.
In my opinion the opposite is true. Having to name and assign takes your focus away from what the algorithm does and focuses on the data or helper functions instead, which is irrelevant. Writing your code mostly pointfree condenses your code to the actual algorithm only.
It's all about how used you are to thinking about functions and not the data that thr functions operate on.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I find the whole line:
the epitome of Haskell's failure to go into mainstream. The whole logic is drawn into a symbolic soup where you forget what you wrote 5 minutes ago and you have to go back and remember what you did.
In parallel here is an implementation in Racket Scheme and how more readable it is:
Here functions have names and they are easier to understand.
Sometimes it pays to be a little bit more verbose.
In my opinion the opposite is true. Having to name and assign takes your focus away from what the algorithm does and focuses on the data or helper functions instead, which is irrelevant. Writing your code mostly pointfree condenses your code to the actual algorithm only.
It's all about how used you are to thinking about functions and not the data that thr functions operate on.