这可能会让你感兴趣:
: double ( n -- n ) dup + ; ! add 2 times
: square ( n -- n ) dup * ; ! multiply 2 times
那么3次呢?
: triple ( n -- n ) dup dup + + ; ! add 3 times
: cube ( n -- n ) dup dup * * ; ! multiply 3 times
(我想知道是否有一种方法可以概括这种模式[..a a a b b b..]
)
那么下一个高阶操作呢: Tetration:
: tetrate2 ( n -- n ) dup ^ ; ! raise to power twice
: tetrate3 ( n -- n ) dup dup ^ ^ ; ! raise to power thrice
You could probably also generalize the other way, implementing hyper-operations like Knuth's up arrow.
It's not immediately apparent to me how one would go about doing that,
but Björn's answer seems to hint at it.
The actual source has a lot of abstraction layers optimizing for the different datatypes.
Clicking thru until it reaches (^fixnum)
gives something similar