[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Line numbers
- To: JNC at MIT-MC (J. Noel Chiappa)
- Subject: Re: Line numbers
- From: Guy.Steele at CMU-10A
- Date: Fri ,24 Oct 80 18:07:00 EDT
- Cc: lisp-forum at MIT-MC
Right on! But single-letter names are few in number. How
about optionally appending a digit? So here is factorial:
(DEFUN FACT (N)
(PROG (A)
10 (SETQ A 1)
20 (IF (= N 0) (RETURN A))
30 (SETQ A (* N A))
40 (SETQ N (- N 1))
50 (GO 20)))
[You think that's funny, hah?! Well, it really is a legal MacLISP
program, and it will work!]
If you prefer recursion to iteration, then how about:
(DEFUN FACT (N)
(PROG (A)
10 (SETQ A 1)
20 (IF (= N 0) (RETURN A))
30 (SETQ N (- N 1))
40 (GOSUB 20)
50 (SETQ N (+ N 1))
60 (SETQ A (* N A))
70 (RETURN A)))
[Not legal MacLISP... yet!]