home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!sousa.ltn.dec.com!kxovax.enet.dec.com!secrist
- From: secrist@kxovax.enet.dec.com (Strong datatypes for weak minds.)
- Newsgroups: comp.lang.lisp.x
- Subject: n! for xlisp
- Keywords: n!
- Message-ID: <1674@sousa.ltn.dec.com>
- Date: 2 Sep 92 13:57:23 GMT
- Sender: newsa@sousa.ltn.dec.com
- Organization: Digital Equipment Corporation
- Lines: 23
-
-
- kan@dg-rtp.dg.com was nice enough to mail me this, which
- works in XLISP V1.1..2.1 and also traps the negative number
- case:
-
- (defun factorial (x)
- (cond ((> x 1) (* x (factorial (- x 1))))
- ((> x -1) 1)
- (t nil)))
-
- I think the error in my ways is that I was using my CP/M
- laptop where XLISP 1.1 only has integers in the range of
- -32768 to +37767 and it was too late for me to notice
- why (factorial 9) didn't work.
-
- (Please don't tell me the error in my ways was using CP/M
- in 1992. I've had my NEC 8400 laptop for ~7 years and can't
- afford anything that small and more powerful on my income...
- otherwise I'd be using Scheme or a Forth-variant like UNTIL.
- Besides, the NEC does words and plays ANSI terminal just fine.)
-
- Regards,
- rcs
-