home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
p4_6dc.seq
< prev
next >
Wrap
Text File
|
1990-04-11
|
770b
|
33 lines
\ Problem 4.6 by Dickson Cheng 04/11/90 15:09:19.85
\ This version is faster because it doesn't need so much stack rotation,
\ and doesn't have to keep track where the sides are.
: XNEW ( n xold -- n xnew )
2DUP / + 2/ ;
: SQRT ( n -- root )
DUP 0< IF ABORT" Illegal argument" THEN
DUP 1 >
IF DUP 2/
10 0 DO XNEW LOOP NIP
THEN ;
VARIABLE A
VARIABLE B
VARIABLE C
: TRI_AREA1 ( a b c -- area )
DEPTH 3 = NOT IF ABORT" Usage: side1 side2 side3 TRI_AREA" EXIT THEN
2 PICK 2 PICK 2 PICK C ! B ! A ! \ store sides A B C
+ + 2/ DUP >R \ store S
A @ - R@ B @ - R@ C @ - R>
* * * SQRT ;