News for hackers. Stuff that matters.
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
Re:Data structures and algorithms I actually used while work... by Smaug123 on Saturday July 18, 2020 @09:07AM (#23881167)
Not in Haskell, it doesn't. Haskell stores everything for you, right?
Re:Data structures and algorithms I actually used while work... by tome on Sunday July 19, 2020 @06:27AM (#23888372)
No, it doesn't.