GNU Forth
$ gforth --version gforth 0.7.3 $ gforth ./gcd.fs 11 22 121 11
$ cat gcd.fs : gcd ( a b -- d ) 2dup > if swap endif over mod dup 0 <> if recurse else drop endif ; : gcdn ( a1 a2 .. an n -- d ) dup 1 > if 1 - rot rot gcd swap recurse else drop endif ; \ This is gforth-specific. \ Usage: \ # gforth ./gcd.fs 11 22 33 121 \ 11 : main 0 >r begin next-arg 2dup 0 0 d<> while s>unumber? if drop else abort endif r> 1 + >r repeat 2drop r> gcdn . cr ; main bye
$ dpkg -s gforth Package: gforth Status: install ok installed Priority: optional Section: interpreters Installed-Size: 481 Maintainer: Peter Pentchev <roam@ringlet.net> Architecture: illumos-amd64 Multi-Arch: foreign Version: 0.7.3+dfsg-4+dyson1 Depends: libc1 (>= 5.10.18.git.2a44663-1), libffcall1 (>= 1.10+2.41), libffi6 (>= 3.0.13-4+dyson1), libltdl7 (>= 2.4.6), emacsen-common (>= 2.0.7), gforth-common (= 0.7.3+dfsg-4+dyson1), gforth-lib (= 0.7.3+dfsg-4+dyson1) Conffiles: /etc/emacs/site-start.d/50gforth.el 1629d9314f2e496f2c476df52bf64e80 Description: GNU Forth Language Environment
Comments