Recent submissions

Comment · 12 years ago
Comment · 12 years ago
I do this sort of thing sporadically in my free time too... it's still good to go back and do stuff smarter when you learn better rather than accepting whatever they taught you in CS101 as the end of the story.
Comment · 12 years ago
Given the guys programming in Javascript and not using arbitrary precision arithmetic, he's always using 64 bits and representing his numbers as floating point, so I don't think you are reasoning correctly about the asympototic complexity here. I mean, if you really want to argue this, then to quote Leibniz: "Calculemus!"

The javascript solution presented does everything in O(n) arithmetic operations, and the SICP way does it in O(ln(n)) arithmetic operations (actually, there are a lot of ways to do it in O(ln(n)) operations).

Comment · 12 years ago
Comment · 12 years ago
If you like doing this sort of thing, there are a million little CS problems like this codewars.com

One cool feature of the site is that you can vote on solutions; this lets you see a lot of neat solutions to problems, and learn a lot about how to write clean code.

Comment · 12 years ago
Comment · 12 years ago
Not corecursive, but here's the SICP O(ln(n)) algorithm:

    fibonacci = fib 1 0 0 1
      where
        fib a b p q n
          | n == 0 = b
          | even n = fib a b p' q' (n `div` 2)
          | otherwise = fib a' b' p q (n - 1)
            where
              p' = p*p + q*q
              q' = 2*p*q + q*q
              a' = a*q + b*q + a*p
              b' = b*p + a*q
Comment · 12 years ago
Functional Programming is a vast subject.

I've really never needed an abstraction for semigroups, monoids, meet-semi-lattices, monads, comonads, arrows or catamorpisms in Clojure, Common Lisp, Scheme, or Hy.

These concepts become more relevant when I program Haskell, Agda, Isabelle/HOL, or Coq.

I'd say a stronger analogy can be made between reading MacLane's Catagories for the Working Mathematician and reading Hoyte's Let Over Lambda; you really only need to read a little bit of these books to get the core concepts. That being said, depending on what sort of functional programming you're doing, a strong background in category theory or meta-programming can enabling (or not).

Comment · 12 years ago
Well, frankly you can get along not knowing the "Gang of Four" design patterns and write Java. By the same token, you don't need to know about iterables and comprehensions to write Python, smart pointers to write C++, Graph theory to use a Graph database, macros to write LISP, etc.

By analogy, you don't need to know abstract algebra and category theory to write Haskell. But as in the other cases, knowing helps.

Comment · 13 years ago
> It's a long road from "gee, I changed something, better copy everything" to something as good as FFTW or ATLAS.

CUDA implementations of FFTs and matrix operations are faster than both FFTW and ATLAS, and they are neither sequential nor functional.

CUDA, C, and Haskell all have domains they typically outperform one another. The math vs. simulation divide sketched in this blog post is more an expression of the author's own psychology more than anything else.

Comment · 13 years ago
> Why should I learn Haskell?

http://stackoverflow.com/questions/1604790/what-is-haskell-a...

For my own 2-cents, once I learned QuickCheck[1] and Parsec[2], I found myself slowly rewriting them for every language I program in.

> Will it help me professionally?

Speaking as another professional, probably not.

I love Haskell, but my colleagues can't deal with it. They can't write it. They don't know functional programming. And to be entirely honest, they will never understand Monoids, Monads, or macro-hacking.

> ...Help me being a better programmer?

Maybe. If you like already like to think of software axiomatically, then yes, it will make you will make you think of software more conceptually.

But honestly, getting javascript, ruby and go under your belt will also make you think differently about software, and those are more practical languages.

[1] http://en.wikipedia.org/wiki/QuickCheck [2] http://www.haskell.org/haskellwiki/Parsec

Comment · 13 years ago
Comment · 13 years ago

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton