home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / p4_6bs.seq < prev    next >
Text File  |  1990-04-14  |  516b  |  28 lines

  1. \ Balraj Sidhu   Set: 14D4
  2. \ Comp 462 - Forth
  3. \ Date: April 12, 1990
  4. \ Problem 4.6
  5.  
  6.  
  7. variable semi
  8.  
  9. : xnew ( n xold -- x xnew )
  10.         2dup / + 2/ ;
  11.  
  12. : sqrt ( n -- root )
  13.         dup 0< if abort" Illegal argument" then
  14.         dup 1 >
  15.         if dup 2/   ( n n/2 )
  16.         10 0 do xnew loop nip
  17.         then ;
  18.  
  19. : cal ( -- )
  20.         semi @ 3 roll - ;
  21.  
  22. : area ( a b c -- area )
  23.         3dup + + 2/ semi !
  24.         cal cal cal
  25.         * * semi @ * sqrt
  26.         cr ." Triangle area is: " . ;
  27.  
  28.