Concatenative topics
Concatenative meta
Other languages
Meta
The Tak function, was invented by Ikuo Takeuchi of the Electrical Communication Laboratory of Nippon Telephone and Telegraph Co., for the purpose of comparing the speeds of LISP systems.
This is one of those nonsensical algorithms that can be used to profile efficiency of a system or language. It was used as a means of testing stack instructions, data moving, and arithmetic.
def tak(x, y, z): if y < x: return tak( tak(x-1, y, z), tak(y-1, z, x), tak(z-1, x, y) ) else: return z
@on-reset ( -> ) #08 #04 #07 tak #010e DEO BRK @tak ( z y x -- res ) LTHk ?{ POP2 JMP2r } ROT ROTk ROTk ( x-1 ) #01 SUB tak STH ( y-1 ) #01 SUB tak STH ( z-1 ) #01 SUB tak STHr STHr !tak
USING: combinators.extras kernel math ; IN: scratchpad : tak ( z y x -- res ) 2dup >= [ 2drop ] [ rot 3dup rot 3dup rot [ 1 - tak ] 3tri@ tak ] if ; 8 4 7 tak .
This revision created on Tue, 19 Mar 2024 19:24:43 by CapitalEx (Add Factor)