Front Page All Articles Recent Changes Random Article

Contents

Concatenative language

  • ACL
  • Ait
  • Aocla
  • Breeze
  • Callisto
  • Cat
  • Cognate
  • colorForth
  • Concata
  • CoSy
  • Deque
  • DSSP
  • dt
  • Elymas
  • Enchilada
  • ETAC
  • F
  • Factor
  • Fiveth
  • Forth
  • Fourth
  • Freelang
  • Gershwin
  • hex
  • iNet
  • Joy
  • Joy of Postfix App
  • kcats
  • Kitten
  • lang5
  • Listack
  • LSE64
  • Lviv
  • Meow5
  • min
  • Mirth
  • mjoy
  • Mlatu
  • Ode
  • OForth
  • Om
  • Onyx
  • Plorth
  • Popr
  • Porth
  • PostScript
  • Prowl
  • Quest32
  • Quackery
  • r3
  • Raven
  • Retro
  • RPL
  • SPL
  • Staapl
  • Stabel
  • Tal
  • Titan
  • Trith
  • Uiua
  • Worst
  • xs
  • XY
  • 5th
  • 8th

Concatenative topics

  • Compilers
  • Interpreters
  • Type systems
  • Object systems
  • Quotations
  • Variables
  • Garbage collection
  • Example programs

Concatenative meta

  • People
  • Communities

Other languages

  • APL
  • C++
  • Erlang
  • FP trivia
  • Haskell
  • Io
  • Java
  • JavaScript
  • Lisp
  • ML
  • Oberon
  • RPL
  • Self
  • Slate
  • Smalltalk

Meta

  • Search
  • Farkup wiki format
  • Etiquette
  • Sandbox

Tak function

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

Uxntal

@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

Factor

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 .

Forth

: tak ( z y x -- n )
    2dup >= if 2drop exit then
    3dup 1- recurse >r
    3dup -rot 1- recurse >r
    rot 1- recurse r> r>
    recurse ;

7 4 8 tak . cr bye

This revision created on Wed, 20 Mar 2024 22:33:30 by soxfox42 (Early exit in forth)

Latest Revisions Edit

All content is © 2008-2024 by its respective authors. By adding content to this wiki, you agree to release it under the BSD license.