![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

Earlier today I wrote this short didactic algorithm to fulfill a request
on comp.lang.forth:
: ascends ( n1 n2 -- lesser greater )
\ ascends arranges the top two numbers on the stack in ascending order.
2DUP > IF SWAP THEN ;
: GCD ( u1 u2 -- u ) \ GCD computes the greatest divisor of n1 and n2.
BEGIN ascends OVER MOD DUP 0= UNTIL DROP ;
"-3 100 GCD" executes, while "3 -100 GCD" hangs. The point is not that
good code exposes a bug in Forth, but that bad (unsafe) code crashes the
window, blocking <alt> and the red "break" icon. Any thoughts?
Jerry
--
"The rights of the best of men are secured only as the
rights of the vilest and most abhorrent are protected."
- Chief Justice Charles Evans Hughes, 1927
"The only thing necessary for the triumph of evil is for
good men to do nothing." - attributed to Edmund Burke 1770?
"They that give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety." - Benjamin Franklin, 1759
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe sftalk" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/sftalk -- check them out!
Search the archives! Visit http://www.forth.com/search for details.
Received on Wed Sep 11 2002 - 12:23:04 PDT
This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:03 PST