Home > Archive > Scheme > February 2008 > New to Scheme,question about quote
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
New to Scheme,question about quote
|
|
|
| Hi All
i am new to Scheme,and have some trouble,may be too silly.
1).why the result of
(car (quote (quote cons)))
is quote?
in my opinion, the process is:
(car (quote (quote cons))) => (car (quote 'cons))
the (quote 'cons) is a list, but the first element of the list
(quote) is not a procedure.
so i even don't think (quote 'cons) is a valid list.
i really don't know the real process that Scheme interpret it.
thanks
| |
| Francisco Ferreira 2008-02-03, 8:39 am |
| On Feb 3, 10:32 am, bob <bobd...@gmail.com> wrote:
> Hi All
>
> i am new to Scheme,and have some trouble,may be too silly.
> 1).why the result of
> (car (quote (quote cons)))
> is quote?
>
> in my opinion, the process is:
> (car (quote (quote cons))) => (car (quote 'cons))
> the (quote 'cons) is a list, but the first element of the list
> (quote) is not a procedure.
> so i even don't think (quote 'cons) is a valid list.
>
> i really don't know the real process that Scheme interpret it.
>
> thanks
I am new to scheme too. At first your question did not surprise me.
I thought, it is perfectly expected (by me) the result. So I started
gambit and tried a few lines. I ended up more .
Gambit Version 4.0 beta 20
> (car (quote (quote cons)))
quote
I think this is because it returns the firs element of the pair, the
first quote.
But, if I do the following?
> (cdr (quote (quote cons)))
(cons)
why is this (cons) instead of (quote cons) or 'cons ??
and then I understand less and less
> (car (cdr (quote (quote cons))))
cons
> (cdr (cdr (quote (quote cons))))
()
>
Thanks
| |
| Stephan Lukits 2008-02-03, 8:39 am |
| Francisco Ferreira schrieb:
> On Feb 3, 10:32 am, bob <bobd...@gmail.com> wrote:
>
> I am new to scheme too. At first your question did not surprise me.
> I thought, it is perfectly expected (by me) the result. So I started
> gambit and tried a few lines. I ended up more .
>
> Gambit Version 4.0 beta 20
>
> quote
Hi,
maybe both of you would like to read:
http://schemers.org/Documents/Stand...7.html#%_idx_86
http://schemers.org/Documents/Stand....html#%_idx_392
If you still have questions: ask again.
regards
Stephan
| |
| Kjetil S. Matheussen 2008-02-03, 8:39 am |
| On Sun, 3 Feb 2008, bob wrote:
> Hi All
>
> i am new to Scheme,and have some trouble,may be too silly.
> 1).why the result of
> (car (quote (quote cons)))
> is quote?
>
(equal? (quote (quote cons))
'(quote cons))
=> #t
(car '(quote cons))
=> quote
(car (quote (quote2 90)))
=> quote2
| |
| Kjetil S. Matheussen 2008-02-03, 7:36 pm |
| On Sun, 3 Feb 2008, Kjetil S. Matheussen wrote:
> On Sun, 3 Feb 2008, bob wrote:
>
>
> (equal? (quote (quote cons))
> '(quote cons))
> => #t
>
(eq? (quote quote)
'quote)
=> #t
(eq? (quote quote2)
'quote2)
=> #t
| |
| Stephan Lukits 2008-02-03, 7:36 pm |
| bob schrieb:
> Hi All
>
> i am new to Scheme,and have some trouble,may be too silly.
> 1).why the result of
> (car (quote (quote cons)))
> is quote?
>
> in my opinion, the process is:
> (car (quote (quote cons))) => (car (quote 'cons))
no, it is: (car '(quote cons))
Whereas (quote cons) is a list which has the symbol quote
as first element and the symbol cons as second element.
> the (quote 'cons) is a list, but the first element of the list
> (quote) is not a procedure.
Why shuld it? and btw the first element of the list is "quote" not
"(quote)"
regards
Stephan
| |
|
| On Feb 3, 10:18 pm, Stephan Lukits <Stephan.Luk...@FernUni-Hagen.de>
wrote:
> bob schrieb:
>
>
>
>
> no, it is: (car '(quote cons))
>
> Whereas (quote cons) is a list which has the symbol quote
> as first element and the symbol cons as second element.
>
>
> Why shuld it? and btw the first element of the list is "quote" not
> "(quote)"
>
> regards
> Stephan
thanks very much.
|
|
|
|
|