Hi,
I'm still a noobie to Lisp so this may be an obvious question. But
I've got a function that generates a list of numbers:
(defun generate-list (len &optional (counter 1))
"Generate-list returns a list of length len: (1 2 3 ... n)."
(if (= len counter)
(list counter)
(cons counter (generate-list len (1+ counter)))))
All pretty simple. Now if I use this with 15 as the argument in CLisp
I get this result:
[4]> (generate-list 15)
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
But if I do the same in abcl I get this:
CL-USER(10): (generate-list 15)
(1 2 3 4 5 6 7 8 9 10 ...)
Is there some configuration setting that I need to change? Trace shows
everything, but the return value is truncated. Does anyone know why?
Thanks in advance.
From: Tamas K Papp
Subject: Re: Ellipsis (...) in abcl output -- how do you get the full result?
Date:
Message-ID: <6vr2noFljk00U1@mid.individual.net>
On Sun, 15 Feb 2009 09:02:55 -0800, webmasterATflymagnetic.com wrote:
> Hi,
>
> I'm still a noobie to Lisp so this may be an obvious question. But I've
> got a function that generates a list of numbers:
>
> (defun generate-list (len &optional (counter 1))
> "Generate-list returns a list of length len: (1 2 3 ... n)." (if (=
> len counter)
> (list counter)
> (cons counter (generate-list len (1+ counter)))))
>
> All pretty simple. Now if I use this with 15 as the argument in CLisp I
> get this result:
>
> [4]> (generate-list 15)
> (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
>
> But if I do the same in abcl I get this:
>
> CL-USER(10): (generate-list 15)
> (1 2 3 4 5 6 7 8 9 10 ...)
>
> Is there some configuration setting that I need to change? Trace shows
> everything, but the return value is truncated. Does anyone know why?
>
> Thanks in advance.
The list is not truncated, the values are there, they are just not
printed. See http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/
HyperSpec/Body/var_stprint-l_int-lengthst.html, eg
(setf *print-length* 25)
or even nil, that will print everything (but be careful if you are
dealing with lists of millions of elements :-)
HTH,
Tamas
On Feb 15, 5:46 pm, Tamas K Papp <······@gmail.com> wrote:
> On Sun, 15 Feb 2009 09:02:55 -0800, webmasterATflymagnetic.com wrote:
> > Hi,
>
> > I'm still a noobie to Lisp so this may be an obvious question. But I've
> > got a function that generates a list of numbers:
>
> > (defun generate-list (len &optional (counter 1))
> > "Generate-list returns a list of length len: (1 2 3 ... n)." (if (=
> > len counter)
> > (list counter)
> > (cons counter (generate-list len (1+ counter)))))
>
> > All pretty simple. Now if I use this with 15 as the argument in CLisp I
> > get this result:
>
> > [4]> (generate-list 15)
> > (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
>
> > But if I do the same in abcl I get this:
>
> > CL-USER(10): (generate-list 15)
> > (1 2 3 4 5 6 7 8 9 10 ...)
>
> > Is there some configuration setting that I need to change? Trace shows
> > everything, but the return value is truncated. Does anyone know why?
>
> > Thanks in advance.
>
> The list is not truncated, the values are there, they are just not
> printed. Seehttp://www.ai.mit.edu/projects/iiip/doc/CommonLISP/
> HyperSpec/Body/var_stprint-l_int-lengthst.html, eg
>
> (setf *print-length* 25)
>
> or even nil, that will print everything (but be careful if you are
> dealing with lists of millions of elements :-)
>
> HTH,
>
> Tamas
Cool. Thanks for this. I knew it would be somewhere in the spec, but
as I've much to learn it's clearly going to take a long time to get
all this knowledge internalised.
Thanks again!
webmasterATflymagnetic.com wrote:
> But if I do the same in abcl I get this:
>
> CL-USER(10): (generate-list 15)
> (1 2 3 4 5 6 7 8 9 10 ...)
>
> Is there some configuration setting that I need to change? Trace shows
> everything, but the return value is truncated. Does anyone know why?
Yes, take a look at the source code. Looks like in
classes/armedbaer/lisp/top-level.lisp in the repl function there is a local
binding (*print-length* 10), so setting your own *print-length*, like
suggested by Tamas, doesn't work. But if you take a look at print.lisp, you
can see that you can try this:
(setf *print-readably* t)
Now it works. I don't know, if this is compliant to Common Lisp, maybe it
is not defined, how the REPL should behave, but in SBCL and LispWorks it
doesn't work the same. I think this could be considered a bug in ABCL,
because I would expect, that my own print-length settings takes precedence
over any internal setting.
--
Frank Buss, ··@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
On Feb 15, 5:55 pm, Frank Buss <····@frank-buss.de> wrote:
> webmasterATflymagnetic.com wrote:
> > But if I do the same in abcl I get this:
>
> > CL-USER(10): (generate-list 15)
> > (1 2 3 4 5 6 7 8 9 10 ...)
>
> > Is there some configuration setting that I need to change? Trace shows
> > everything, but the return value is truncated. Does anyone know why?
>
> Yes, take a look at the source code. Looks like in
> classes/armedbaer/lisp/top-level.lisp in the repl function there is a local
> binding (*print-length* 10), so setting your own *print-length*, like
> suggested by Tamas, doesn't work. But if you take a look at print.lisp, you
> can see that you can try this:
>
> (setf *print-readably* t)
>
> Now it works. I don't know, if this is compliant to Common Lisp, maybe it
> is not defined, how the REPL should behave, but in SBCL and LispWorks it
> doesn't work the same. I think this could be considered a bug in ABCL,
> because I would expect, that my own print-length settings takes precedence
> over any internal setting.
>
> --
> Frank Buss, ····@frank-buss.dehttp://www.frank-buss.de,http://www.it4-systems.de
Thanks for this. I tried Tamas' solution and it didn't work, so this
explains it. But surely not a bug -- I cannot believe someone as green
behind the ears as I am, as far as Lisp is concerned, has found a
bug. ;-)
But hints from everyone certainly helps. I know I'm only currently
crawling along with Lisp, but I do know it is *the* mountain to climb.
Working through Norvig's and Graham's books keeps making my head hurt
- and each time with only half a dozen lines of code!
So no giving up...
webmasterATflymagnetic.com <·········@flymagnetic.com> wrote:
+---------------
| Frank Buss <····@frank-buss.de> wrote:
| > I think this could be considered a bug in ABCL, because I
| > would expect that my own print-length settings takes precedence
| > over any internal setting.
|
| Thanks for this. I tried Tamas' solution and it didn't work, so this
| explains it. But surely not a bug -- I cannot believe someone as green
| behind the ears as I am, as far as Lisp is concerned, has found a bug. ;-)
+---------------
Actually, you probably *have* found a bug! Beginners often poke around
in corners where the more experienced seldom go, and are thus more
likely to stumble on things in some specific implementation that no-one
has tried before. Or in this particular case, stumble onto an issue
that a more experienced Lisper would just work around [perhaps with
a (WRITE * :LENGTH NIL)] and move on, without bothering to complain
to anyone. ;-}
If there is a defined procedure for doing so, please do take the time
to file a bug report with the ABCL maintainers, for the sake of the
*next* generation of beginners...
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
On Feb 16, 3:08 am, ····@rpw3.org (Rob Warnock) wrote:
> webmasterATflymagnetic.com <·········@flymagnetic.com> wrote:
>
> +---------------
> | Frank Buss <····@frank-buss.de> wrote:
> | > I think this could be considered a bug in ABCL, because I
> | > would expect that my own print-length settings takes precedence
> | > over any internal setting.
> |
> | Thanks for this. I tried Tamas' solution and it didn't work, so this
> | explains it. But surely not a bug -- I cannot believe someone as green
> | behind the ears as I am, as far as Lisp is concerned, has found a bug. ;-)
> +---------------
>
> Actually, you probably *have* found a bug! Beginners often poke around
> in corners where the more experienced seldom go, and are thus more
> likely to stumble on things in some specific implementation that no-one
> has tried before. Or in this particular case, stumble onto an issue
> that a more experienced Lisper would just work around [perhaps with
> a (WRITE * :LENGTH NIL)] and move on, without bothering to complain
> to anyone. ;-}
>
> If there is a defined procedure for doing so, please do take the time
> to file a bug report with the ABCL maintainers, for the sake of the
> *next* generation of beginners...
>
> -Rob
>
> -----
> Rob Warnock <····@rpw3.org>
> 627 26th Avenue <URL:http://rpw3.org/>
> San Mateo, CA 94403 (650)572-2607
OK, wilco. And thanks for making me feel special. (But hey, wait a
minute -- I am special: I'm slowly learning Lisp. What can be more
special than that?)
From: Thomas A. Russ
Subject: Re: Ellipsis (...) in abcl output -- how do you get the full result?
Date:
Message-ID: <ymi3aecin95.fsf@blackcat.isi.edu>
Frank Buss <··@frank-buss.de> writes:
> classes/armedbaer/lisp/top-level.lisp in the repl function there is a local
> binding (*print-length* 10), so setting your own *print-length*, like
> suggested by Tamas, doesn't work. But if you take a look at print.lisp, you
> can see that you can try this:
Interstingly, Allegro CL uses its own additional print control special
variable for top level REPL printing to set the default. So although
they also bind *PRINT-LENGTH*, they bind it to the value of another
variable that you can set: TPL:*PRINT-LENGTH* (as well as
TPL:*PRINT-LEVEL*).
This seems to try to address both issues, but it is a bit disorienting
the first time you run into a situation where the REPL seems to be
disregarding the print control variables.
--
Thomas A. Russ, USC/Information Sciences Institute