Re:Data structures and algorithms I actually used while work...
by eru on Wednesday July 15, 2020 @06:44AM
(#23843443)
Why do you need so many lines?
[ Parent
| on HN ]
Re:Data structures and algorithms I actually used while work...
by exdsq on Wednesday July 15, 2020 @07:01AM
(#23843555)
Because the three liner is easier to read
Re:Data structures and algorithms I actually used while work...
by eru on Wednesday July 15, 2020 @07:07AM
(#23843596)
Btw, which three-liner do you mean?
Re:Data structures and algorithms I actually used while work...
by exdsq on Friday July 17, 2020 @04:04AM
(#23868296)
fib 0 = 0
fib 1 = 1
fib n = fib (n-1) + fib (n-2)
Re:Data structures and algorithms I actually used while work...
by eru on Saturday July 18, 2020 @04:32AM
(#23879997)
Oh, that version takes exponential time to compute. The one-liner I gave computes up to the n-th Fibonacci number in linear time.
Re:Data structures and algorithms I actually used while work...
by exdsq on Saturday July 18, 2020 @07:00AM
(#23880520)
Your version is definitely more performant, but the three liner is just a bit nicer to read (especially for beginners) :)
Re:Data structures and algorithms I actually used while work...
by eru on Saturday July 18, 2020 @07:54AM
(#23880764)
Yes. It depends on what you want to show. Your version shows how to define functions and some simple pattern matching.
Re:Data structures and algorithms I actually used while work...
by exdsq on Tuesday July 21, 2020 @03:40AM
(#23905047)
Having worked with Haskell for a year now I still can't read much more than functions and pattern matching! :D