makelist(): argument size appears restricted to integer -- RFC
Subject: makelist(): argument size appears restricted to integer -- RFC
From: Robert Dodier
Date: Tue, 21 Apr 2009 08:31:55 -0600
On 4/21/09, Robyn Dawn Hannigan <sonofthejedi at xtra.co.nz> wrote:
> (%i1) s(n):= block([n:n],
> apply("+",map(lambda([x],x^2),makelist(x,x,1,n))))$
> (%i2) s(30!);
> If 4 arguments are given to MAKELIST, the difference of the 3rd and 4th
> arguments should evaluate to a non-negative integer:
> 265252859812191058636308479999999
> #0: s(n=265252859812191058636308480000000)
There are 2 kinds of integers, fixed-size integers and arbitrary-size
integers. makelist is looking for a fixed-size integer. Which is, I guess,
a bug, although maybe not important in practice; it seems possible
that a typical computer might take a very long time to compute s(30!)
or it might run out of memory before finishing.
If you are curious, you could redefine FIXNUMP as follows:
:lisp (defun fixnump (x) (integerp x))
Or apply the patch below and reload mstuff.lisp.
FWIW
Robert Dodier
PS.
--- src/mstuff.lisp 19 Aug 2008 14:47:26 -0000 1.11
+++ src/mstuff.lisp 21 Apr 2009 14:28:31 -0000
@@ -51,7 +51,7 @@
the 3rd argument should evaluate to a list:~%~M" a)))
(t
(setq b (meval (cadddr x)))
- (if (or (not (fixnump (setq d (sub* b a)))) (< d -1))
+ (if (or (not (integerp (setq d (sub* b a)))) (< d -1))
(merror "If 4 arguments are given to
MAKELIST, the difference of the 3rd ~
and 4th arguments should evaluate to a non-negative integer:~%~M" d)
(interval a b)))))