home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / tipi / powers.tpi < prev    next >
Text File  |  1993-11-06  |  480b  |  29 lines

  1. # POWERS.TPI
  2. # by Kent Peterson
  3.  
  4. # This is a simple program to demonstrate
  5. # how easy it is to add new instructions
  6. # to TIPI.
  7.  
  8. define square ( n -- n*n )
  9. # Squares a number
  10.  dup *
  11. enddef
  12.  
  13. define cube ( n -- n*n*n )
  14. # Cubes a number
  15.  dup square *
  16. enddef
  17.  
  18. define quad ( n -- n*n*n*n )
  19. # raises a number to the fourth power
  20.  square dup *
  21. enddef
  22.  
  23. "Enter a number" print$
  24. getnum
  25. dup square print cr
  26. dup cube   print cr
  27.      quad   print cr
  28. begin key until
  29.