Hi!
Clisp-print-function prints the same in two lines. For example, the
following lines are the output from terminal:
[1]> (print 'hello)
HELLO
HELLO
[2]>
I'd like to set some option in order to print only 1 line!
My CLISP is installed in Linux. Today I re-installed CLISP package
trying to solve the problem, but no solution.
Thanks!
"Sergio" <······@gmail.com> writes:
> Hi!
> Clisp-print-function prints the same in two lines. For example, the
> following lines are the output from terminal:
>
> [1]> (print 'hello)
>
> HELLO
> HELLO
> [2]>
Two things happen: First, you tell it to print 'hello, second it
prints the return values of print, which is 'hello.
> I'd like to set some option in order to print only 1 line!
You don't really want to do that.
However, you can write your own print function that doesn't return
any values (by letting it return an empty value list: (values)),
or you can use the built-in PPRINT, which (unlike PRINT) has
zero return values (it also pretty prints, which may be your
intention anyway):
CAPI-E 46 > (pprint 'hello)
HELLO
CAPI-E 47 >
--
(espen)
"Sergio" <······@gmail.com> writes:
> Hi!
> Clisp-print-function prints the same in two lines. For example, the
> following lines are the output from terminal:
>
> [1]> (print 'hello)
>
> HELLO
> HELLO
> [2]>
>
>
> I'd like to set some option in order to print only 1 line!
> My CLISP is installed in Linux. Today I re-installed CLISP package
> trying to solve the problem, but no solution.
What you have is a REPL. Did you know it?
Have you any idea what REPL means?
It means: Read Eval Print Loop.
Do you notice anything?
read eval PRINT loop !
It's implemented as: (loop (print (eval (read))))
well, actually it's slightly more complex, since it catch errors, and
prints a prompt, and keep track of the last few expressions evaluated,
but the basic functionality is (loop (print (eval (read)))).
So you already get a free print. Why would you try to print it a second time?
Just type:
[1]> 'hello
HELLO
[2]>
Try also:
[2]> (print (print (print 'hello)))
HELLO
HELLO
HELLO
HELLO
[3]>
--
__Pascal Bourguignon__ http://www.informatimago.com/
"You can tell the Lisp programmers. They have pockets full of punch
cards with close parentheses on them." --> http://tinyurl.com/8ubpf
On Fri, 08 Sep 2006 14:07:36 +0200, Sergio <······@gmail.com> wrote:
> Hi!
> Clisp-print-function prints the same in two lines. For example, the
> following lines are the output from terminal:
>
> [1]> (print 'hello)
>
> HELLO
> HELLO
> [2]>
>
>
> I'd like to set some option in order to print only 1 line!
> My CLISP is installed in Linux. Today I re-installed CLISP package
> trying to solve the problem, but no solution.
>
> Thanks!
>
Or ugh.. (progn (print 'hello) (values))
This is a way to make a function return nothing.
It makes more sense in a function where you have
many print's.
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: Ken Tilton
Subject: Re: CLISP - a little problem with print function
Date:
Message-ID: <KwBMg.38$y95.34@newsfe09.lga>
> On Fri, 08 Sep 2006 14:07:36 +0200, Sergio <······@gmail.com> wrote:
>
>> Hi!
>> Clisp-print-function prints the same in two lines. For example, the
>> following lines are the output from terminal:
>>
>> [1]> (print 'hello)
>>
>> HELLO
>> HELLO
>> [2]>
>>
>>
>> I'd like to set some option in order to print only 1 line!
This is a little confusing. The function PRINT happens to return a
value, namely the thing it is asked to print. The P in REPL stands for
"print". So here is what happens:
You ask the CLisp repl to evaluate (Print 'hello).
Evaluating that causes the PRINT function to run and, since no output
stream is specified, it defaults to the same window as the REPL. So you
see the first HELLO appear.
Print then returns the value 'HELLO.
The CLisp REPL dutifully prints out what PRINT returned: HELLO, so you
see it a second time.
ie, don't worry about it. :) but it is useful to understand the sequence.
kt
--
Cells: http://common-lisp.net/project/cells/
"I'll say I'm losing my grip, and it feels terrific."
-- Smiling husband to scowling wife, New Yorker cartoon
Ken Tilton <·········@gmail.com> wrote:
+---------------
| > Sergio <······@gmail.com> wrote:
| >> [1]> (print 'hello)
| >> HELLO
| >> HELLO
| >> [2]>
| >> I'd like to set some option in order to print only 1 line!
...
| ie, don't worry about it. :) but it is useful to understand the sequence.
+---------------
One of these examples often stimulates the needed "Aha!":
> (* 2 (print 123))
123
246
> (symbol-name (print 'foo))
FOO
"FOO"
>
Once the person groks those, the results of (PRINT 123)
or (PRINT 'FOO) by themselves become obvious.
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
From: Ken Tilton
Subject: Re: CLISP - a little problem with print function
Date:
Message-ID: <KhNMg.98$y95.85@newsfe09.lga>
Rob Warnock wrote:
> Ken Tilton <·········@gmail.com> wrote:
> +---------------
> | > Sergio <······@gmail.com> wrote:
> | >> [1]> (print 'hello)
> | >> HELLO
> | >> HELLO
> | >> [2]>
> | >> I'd like to set some option in order to print only 1 line!
> ...
> | ie, don't worry about it. :) but it is useful to understand the sequence.
> +---------------
>
> One of these examples often stimulates the needed "Aha!":
>
> > (* 2 (print 123))
> 123
> 246
> > (symbol-name (print 'foo))
> FOO
> "FOO"
> >
>
So verbose!
> (list :the :evaluation :is (print `(I hereby print 42)))
(I HEREBY PRINT 42)
(:THE :EVALUATION :IS (I HEREBY PRINT 42))
kt