Lurker News
Preferably an elegant snippet rather than an entire (well engineered) codebase.

Comments (380) 116 threads

Earlier comments
seisvelas1 reply#
You are the second person to reference quicksort in Haskell in this thread. The other person even mentioned it not being true quicksort. Who knew quicksort in Haskell was such a beloved piece of code!
abecedarius#
Back when HotOrNot was hot, there was a site like it for rating code snippets. The top-rated one, I think I remember, was a broken version of this sort function: it had left out the recursions or something (I don't remember exactly), which made it even more 'elegant'.

This wasn't the only case I noticed of highly-rated broken code there. It took me a long time to take this lesson to heart about especially slick-looking code of my own.

Hnrobert421 reply#
Along these lines, does anyone else have the experience of reading some code and thinking “Damn this is good. So clear, so well formatted,” only to realize moments later with a bit of embarrassment that it is your own code?
mceachen#
Or, worse, "who was the idiot that wrote this?"

... git blame ...
oh. me.

nils-m-holm#
Unification of the terms X and Y in the environment E in LISP (part of a PROLOG interpreter):

    (defun unify (x y e)
      (let ((x (look-up x e))
            (y (look-up y e)))
        (cond ((eq x y) e)
              ((variable-p x) (cons (list x y) e))
              ((variable-p y) (cons (list y x) e))
              ((or (atom x) (atom y)) nil)
              (#t (let ((ne (unify (car x) (car y) e)))
                    (and ne (unify (cdr x) (cdr y) ne)))))))
LOOK-UP looks up X or Y in E, VARIABLE-P returns truth, if X or Y is a variable.

Load more comments