Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Knuth's up-arrow notation

Name: Anonymous 2007-08-07 11:37 ID:ywrNHFyl

(defun knuth (x n)
  (if (= n 2)
      (return-from knuth (expt x x))
    (return-from knuth (expt x (knuth x (- n 1))))
    )
)


Yes, an implementation in 6 lines of Lisp. What is Knuth's up-arrow notation? Wikipedia that shit. Don't try this with anything greater than (knuth 3 3), or you will overflow. (knut 3 3) == 3^3^3. (knuth 3 4) == 3^3^3^3.

Name: Anonymous 2007-08-08 14:24 ID:mNCp9Qs0

>>35
Yes, because >>32 just leaps out and screams at me what its algorithm is. Oh, wait, it doesn't. If you claim it does, you're self-deluded.

I'm not partial to Lisp for other reasons, but even with all those parens it's far more readable. You don't need to do shit in reverse order and keeping a stack in your head.

And then there's the other functional languages, which are a huge improvement over Lisp readability-wise. Which leaves Factor permanently in the toy department. Forth was and is a dead end.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List