(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:
Anonymous2007-08-08 22:21 ID:DDRzupTb
>>36
it's pretty obvious to me that it makes 2 arrays, appends them together, converts the result to a quotation, and then calls it.
and it only has 1 shuffle word.
keep ( x quot -- x )
...
Inputs and outputs
quot a quotation with stack effect ( x -- )
x an object
Word description
Call a quotation with a value on the stack, restoring the value when the quotation returns.
Name:
Anonymous2007-08-08 23:19 ID:PytvNh+C
>>41
You're telling me you find it as readable as the versions in other languages on this page? Maybe you do, and all the more power to you; I have a really hard time believing it though.
Tell you what: make the absolute most readable version in Factor that you can. I have as much experience in Factor as I do in Lisp, Haskell, ML, and so forth, so I don't know the idioms of any of them. Convince me.
Name:
Anonymous2007-08-08 23:36 ID:X4nQBBK3
: knuth ( x y -- z ) [ swap <array> ] keep 1- \ ^ <array> append >quotation call ;
ok, so...
"(n elt) <array>" creates an array of length n, initialized to elt. so basically <array> = replicate
keep = over slip, over = xy-xyx, slip calls a quotation ignoring the top element, so, the quotation is called, but the top element is kept. or something like that. anyway after keep the stack is something like
>>45
\ escapes the ^ so it's pushed onto the stack instead of called.
also, 1- doesn't subtract from 1, it subtracts 1 from whatever number is on the top of the stack. so it's y-1, not 1-y.
>>44 : knuth ( x y -- z ) 2dup zero? [ 3drop 1 ] [ swap 1- knuth ^ ] if ;
or : knuth ( x y -- z ) swap <array> 1 [ swap ^ ] reduce ;
is probably the most readable.
but i really like the fact that >>32 only uses one shuffle word.
Name:
Anonymous2007-08-09 2:48 ID:6QSw4CgV
>>33
Yeah, good luck appreciating well written code in a language you dont have a clue about...
>>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.
Name:
Anonymous2007-08-10 0:04 ID:/jdb7tRc
>>56
it's the equivalent to foldr plus replicate. it's not that obscure, and I don't even know factor (i'm the guy who proposed the iterate version)
>>59
keeping a stack containing less than 5 elements in your head is easier than counting 20 pairs of parentheses.
if you go deeper than that on the stack you're probably doing something wrong.
Name:
Anonymous2007-08-10 6:55 ID:1+RtKdzc
>>60
you don't have to, ahem, actually count the parentheses.
>>66
You seem to be a so-called ``EXPERT BBCODE PROGRAMMER''. In the wake of BBCode 3.0, I'm writing a Haskell library that enables mere mortals to write ``proper'' BBCode. What particular BBCode features do you find useful? What kind of functionality do you except from an ENTERPRISE-quality BBCode solution?
Name:
Anonymous2007-08-10 15:46 ID:AGvIsGMx
>>67
ABSTRACT BULLSHITE and turn "" into 66proper quotes99
Name:
Anonymous2007-08-10 17:01 ID:SPbFvEWz
>>67 (((ok bitch) (you asked for it) (here goes)) (im taking out the fucking (bold paranthesis on you)) (you fuqing angered an expert programmer) (ive been here for(expt 3 88888000)years longer than you) (ive read sicp twice) (i know every programming language in the world including apl) (if u wanna batl(lets do it)) (ill crush you like a bean))
Name:
Anonymous2007-08-11 7:29 ID:FLZoZQXk
>>69
lmao, well reverse engineerd.. you are fastly approaching BBCode satori
Name:
Anonymous2007-08-11 14:10 ID:3UvjmHTM
I LISTEN TO INFECTED MUSHROOM WHILE I WRITE JAVA BECAUSE I AM 1337
Name:
Anonymous2007-08-11 15:57 ID:FLZoZQXk
sage for failed lisp formatting in OP, dont put the parens like that you dick