|
|
|
|
|
by progman
3158 days ago
|
|
> : right# negate 32 + . ; This is an example of "ugly" Forth code. It's ok here to make the code as short as possible. In reality I would write (educational) Forth code this way. The texts in parentheses are comments. ( compute Hypotenuse sqrt[a²+b²] )
: hypo ( a b )
swap ( b a )
dup * ( b a² )
swap ( a² b )
dup * ( a² b² )
+ ( a²+b² )
sqrt ( result )
;
( Application: 1.2 3.4 hypo )
|
|