Things that seem funny to me: A passionate Buddhist A compassionate Republican A courageous Democrat A fool writing list of funny things… If you seek, you will find... what you seek. Somtimes you find only yourself. When you seek a great truth and you find your great truth you might not like what it looks like. Be brave enough to look anyway.
...in Germany, "party should be just the thing to get everyone off on the right ... more than the barest suggestion he 'set things up here' she felt justified in a ... aboard one of those monsters is already brave, but if doing it three times to go... she finished indignantly. 'I forgot to say something. You did a good, bravething today.' Shinji shook off the memory of the first real praise he'...
... could move stuff to a new array. It's got to be faster to do MOVE than to @ a lot of things onto the stack. : r { count xt } \ x1..xn n xt -- y, where y = result begin count 1...= result ) begin over 1- while 2dup r (r) 1+ 2/ swap repeat ; A minor thing -- dup 2/ swap 1 and + == 1+ 2/ Is it worth learning that sort of minor trick?
...; that's what the line "2 pick 0= if swap then" is about. Yes, exactly. Another interesting thing is that the trees built in this way are different from the trees build by my depth-first version: ... a little bit more. But I'll use your depth-first ones if I ever need this sort of thing. It makes much more sense to me to have the tree structure be explicit, instead of being a side ...
... it with one element from the next tree level right away, instead of propagating it into the next tree-level as-is; that's what the line "2 pick 0= if swap then" is about. Another interesting thing is that the trees built in this way are different from the trees build by my depth-first version: E.g., with 10 elements, the root node built by MY-REDUCE has one subtree with 4 leaves, and ...
...pushes a 0, then n leaves, then calls your implementation of reduce over those leaves. The final tree is walked: its leftmost child must be a 1, and walk-tree checks that each leaf is equal to two plus the previous leaf in the walk order. This is fast but leaves the tree on the dictionary area; use marker to clean things away afterwards (or simply ignore the problem). --Thomas Pornin
...>r dup 2/ tuck - r@ rot r ( x1 ... xu xt R: xt u2 ) recurse r@ rot r recurse execute then ; This also worked on the first run. Again, there are too many things going on on the return stack, but putting the xt on the bottom works pretty well here, and using a DEFERed word for the xt would not help as much as one might hope. Now, instead of using COUNT-OPERANDS, I ...
...recursion, especially in this case. I should have tried harder to eliminate the global deferred word. I like your version as above best. It's great to see so many different ways of doing the same thing. This really helps my learning. We should have these sorts of threads more often on this newsgroup, I think! - anton -- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home...
... to factor it? Robert apologised for using a deferred variable. I don't see this as likely to be re-entrant. To make it re-entrant the execution token itself would need to call reduce to operate on a list of things, in the process of doing ( x1 x2 -- x3 ). That could happen. If it's rare, you could save the old xt on the return stack and restore it when you're done. A little extra trouble but ...
... stack? That's why there are two WHILEs in the first inner loop; the first exits on 0 elements left, the second on 1 element left. Â Note also the cunning between the REPEAT and the THEN to undo the R between the first and the second WHILE. I have tested it with 1..100 things on the stack, and it works. Sorry I missed that subtlety, I should have tried it. Gerry