all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: bigger integers
@ 2004-09-03 22:00 Joe Corneli
  0 siblings, 0 replies; 11+ messages in thread
From: Joe Corneli @ 2004-09-03 22:00 UTC (permalink / raw)


   After all, emacs lisp is designed to count characters in a file,
   not to compute factorials.

 "Emacs is the extensible, customizable, self-documenting real-time
 display editor."

If I can't extend or customize it to compute 12! then there seems to
be something missing.  Kevin's factorial works though so I guess
that's good enough for me... oh wait a second now it stopped working.

  Debugger entered--Lisp error: (error "Lisp nesting exceeds max-lisp-eval-depth")
  (factorial (1- num))
  (* num (factorial (1- num)))
  (if (<= num 0) 1.0 (* num (factorial ...)))
  factorial(7)
  (* num (factorial (1- num)))
  (if (<= num 0) 1.0 (* num (factorial ...)))
  factorial(8)
  (* num (factorial (1- num)))
  (if (<= num 0) 1.0 (* num (factorial ...)))
  factorial(9)
  (* num (factorial (1- num)))
  (if (<= num 0) 1.0 (* num (factorial ...)))
  factorial(10)
  (* num (factorial (1- num)))
  (if (<= num 0) 1.0 (* num (factorial ...)))
  factorial(11)
  (* num (factorial (1- num)))
  (if (<= num 0) 1.0 (* num (factorial ...)))
  factorial(12)
  eval((factorial 12))

(This same computation was fine just a minute ago, then I tried to
compute 100! and now it doesn't want to do 12! any more.)

   I think calc can cope with arbitrary precision.

I guess I'll check that out.

^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <mailman.1438.1094249173.1998.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.1324.1094164438.1998.help-gnu-emacs@gnu.org>]
* bigger integers
@ 2004-09-02 22:28 Joe Corneli
  0 siblings, 0 replies; 11+ messages in thread
From: Joe Corneli @ 2004-09-02 22:28 UTC (permalink / raw)



This fails on big numbers like 12.

 (defun factorial (num)
   (if (<= num 0)
       1
     (* num (factorial (1- num)))))

Suggestions on how to make it work for bigger numbers?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2004-09-17 19:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-03 22:00 bigger integers Joe Corneli
     [not found] <mailman.1438.1094249173.1998.help-gnu-emacs@gnu.org>
2004-09-03 23:29 ` Pascal Bourguignon
2004-09-07 17:46 ` Kevin Rodgers
     [not found] <mailman.1324.1094164438.1998.help-gnu-emacs@gnu.org>
2004-09-02 23:10 ` Kevin Rodgers
2004-09-03  2:11 ` Pascal Bourguignon
2004-09-03 10:20 ` Phillip Lord
2004-09-04  8:18 ` Alan Mackenzie
2004-09-04 11:09   ` Neil Woods
2004-09-06  0:00 ` Miles Bader
2004-09-17 19:45 ` giacomo boffi
  -- strict thread matches above, loose matches on Subject: below --
2004-09-02 22:28 Joe Corneli

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.