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-09 11:19 ID:9s7U1jSL

>>47
I don't have a clue about Lisp or Haskell either, yet I have no problem working out what most of the code is doing. Factor's problem is that you need to keep a stack in your head.

Also, I like the second version in >>46, even if it's still obscure to me.

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