From: ······@gmail.com
Subject: Print a (
Date: 
Message-ID: <1170378538.962966.268900@l53g2000cwa.googlegroups.com>
Hi,
How do I print out a '(' or ')' as part of a list?
Thanks

From: Lars Rune Nøstdal
Subject: Re: Print a (
Date: 
Message-ID: <pan.2007.02.02.01.25.15.36550@gmail.com>
On Thu, 01 Feb 2007 17:08:59 -0800, axsmth wrote:

> Hi,
> How do I print out a '(' or ')' as part of a list?
> Thanks

cl-user> (dolist (elt '(#\a #\( #\b #\c #\) #\d))
           (format t "~C~%" elt))
a
(
b
c
)
d


...?

-- 
Lars Rune Nøstdal
http://nostdal.org/
From: ······@gmail.com
Subject: Re: Print a (
Date: 
Message-ID: <1170381124.850598.142920@a34g2000cwb.googlegroups.com>
Hi,
Ya thats rite but then I need to pass that list for further evaluation
say
cl-user> (dolist (elt '(#\( 2 * #\c 3) ))
           (format t "~C~%" elt))


(
2
*
3
)

Now can this be passed as code to some function so that it evalutates?
( to 6 in this case)
Thanks
From: D Herring
Subject: Re: Print a (
Date: 
Message-ID: <69SdnfwU5P9wOV_YnZ2dnUVZ_oytnZ2d@comcast.com>
······@gmail.com wrote:
> Hi,
> Ya thats rite but then I need to pass that list for further evaluation
> say
> cl-user> (dolist (elt '(#\( 2 * #\c 3) ))
>            (format t "~C~%" elt))
...
> Now can this be passed as code to some function so that it evalutates?
> ( to 6 in this case)
> Thanks

(let ((str (format nil "~S~%" '(* 2 3))))
   (eval (read-from-string str)))
From: Lars Rune Nøstdal
Subject: Re: Print a (
Date: 
Message-ID: <pan.2007.02.02.02.36.22.489133@gmail.com>
On Thu, 01 Feb 2007 17:52:04 -0800, axsmth wrote:

> Hi,
> Ya thats rite but then I need to pass that list for further evaluation
> say
> cl-user> (dolist (elt '(#\( 2 * #\c 3) ))
>            (format t "~C~%" elt))
> 
> 
> (
> 2
> *
> 3
> )
> 
> Now can this be passed as code to some function so that it evalutates?
> ( to 6 in this case)
> Thanks


Uhm, are you trying to do something like:


cl-user> (defmacro blah (expr)
           `(,(second expr) ,(first expr) ,(third expr)))
blah
cl-user> (blah (2 * 3))
6


See http://plaza.ufl.edu/lavigne/infix.lisp

-- 
Lars Rune Nøstdal
http://nostdal.org/
From: Lars Rune Nøstdal
Subject: Re: Print a (
Date: 
Message-ID: <pan.2007.02.02.02.38.45.621775@gmail.com>
Maybe it'll be easier/quicker if you state your goal with this instead of
asking for bits and pieces.

-- 
Lars Rune Nøstdal
http://nostdal.org/
From: Harold Lee
Subject: Re: Print a (
Date: 
Message-ID: <1170453632.536371.164930@v33g2000cwv.googlegroups.com>
On Feb 1, 6:36 pm, Lars Rune Nøstdal <···········@gmail.com> wrote:
>
> Seehttp://plaza.ufl.edu/lavigne/infix.lisp
>
> --
> Lars Rune Nøstdalhttp://nostdal.org/

When I was learning about reader macros, I wrote some code similar to
this to take anything in curly braces and parse it using a pseudo C/
Java expression syntax and build a Lisp expression from it. Thus { 1+2
* 3+4 } is converted at read time to (+ (+ 1 (* 2 3)) 4) which
evaluates to 11. Just a toy, but a fun exercise. Perhaps that's what
the OP means to do?
From: ······@gmail.com
Subject: Re: Print a (
Date: 
Message-ID: <1170484669.596598.26310@a75g2000cwd.googlegroups.com>
Yes, I am trying to generate an expression and evaluate it as well.
Thanks
From: Pascal Bourguignon
Subject: Re: Print a (
Date: 
Message-ID: <87bqkbv41u.fsf@thalassa.informatimago.com>
······@gmail.com writes:

> Yes, I am trying to generate an expression and evaluate it as well.

Well you see, the problem is that in lisp, there are no parentheses.
http://groups.google.com/group/comp.lang.lisp/msg/6ec4dab4a8d57f6e

Lists are NOT built with parentheses "around".  

Lists are built by chaining small records of two fields, named CONS
cells (because they're created by the function CONS which CONStructs
them).  (And the end of the list is denoted by the symbol NIL).



So if you want to generate the expression (+ 1 2), you will execute
the expression:

   (cons (quote +) (cons 1 (cons 2 nil)))
   --> (+ 1 2)

and you can evaluate it:

   (let ((expression (cons (quote +) (cons 1 (cons 2 nil)))))
      (eval expression))
   --> 3


Now, of course this CONS function is rather low level.  You can build
that expression more easily with the function LIST, which just calls
CONS for you:

   (list (quote +) 1 2) == (cons (quote +) (cons 1 (cons 2 nil)))

You can also use the function LIST* when you have a tail:

  (let* ((arguments (list 3 4))
         (expression (list* (quote +) 1 2 arguments)))
    (eval expression))
  --> 10
      
You can also use the backquote reader macro with comma and unsplice:

   (let ((a 1)   
         (b 2)
         (op '+))
      (eval `(,op ,a ,b)))
   --> 3

there are a lot of functions you can use to build lists and
expressions, but none of them is concerned about any parenthesis
because this is something that doesn't exist IN lisp.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"Indentation! -- I will show you how to indent when I indent your skull!"
From: Lars Rune Nøstdal
Subject: Re: Print a (
Date: 
Message-ID: <pan.2007.02.03.15.54.50.237938@gmail.com>
On Sat, 03 Feb 2007 13:06:21 +0100, Pascal Bourguignon wrote:

> ······@gmail.com writes:
> 
>> Yes, I am trying to generate an expression and evaluate it as well.
> 
> Well you see, the problem is that in lisp, there are no parentheses.

http://www.gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-processing.html#there-is-no-list

lol

-- 
Lars Rune Nøstdal
http://nostdal.org/
From: Thomas A. Russ
Subject: Re: Print a (
Date: 
Message-ID: <ymihcu0ay87.fsf@sevak.isi.edu>
······@gmail.com writes:

> Hi,
> Ya thats rite but then I need to pass that list for further evaluation
> say
> cl-user> (dolist (elt '(#\( 2 * #\c 3) ))
>            (format t "~C~%" elt))
> 
> 
> (
> 2
> *
> 3
> )
> 
> Now can this be passed as code to some function so that it evalutates?
> ( to 6 in this case)

In your original question (and the subject), you requested PRINTing, not
CONStructing list objects to pass to other code.

Printing is used for communicating with the outside world or for
persisting data into files.  It is not (generally) used inside running
code for communication purposees.

If you want to create a list, then you use the list creation functions
such as CONS or LIST or other variants there-of.

For example, (list '2 '* '3)  gives you a list structure that can then
be used by other code.

This is an instance where it would be better to describe what the larger
goal is that you have in mind rather than asking very low-level
questions about how to do some small step that you think may be on that
path.


-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: André Thieme
Subject: Re: Print a (
Date: 
Message-ID: <epu7fv$7aj$1@registered.motzarella.org>
······@gmail.com schrieb:
> How do I print out a '(' or ')' as part of a list?

(format t "~a" '(a b c d e))


-- 
Andr�