For Programmers: Free Programming Magazines  


Home > Archive > Scheme > September 2006 > scheme without nil









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 scheme without nil
perltcl@yahoo.com

2006-09-13, 7:04 pm

hi

how do you get a list like
(list 1 2 3 4)
( 1 2 3 4)
when your scheme implementation do not have "nil" and "list" ?


I've tried :
(cons 1 (cons 2 (cons 3 4)))

but it gave me:
(1 2 3 . 4)

thanks.

Raffael Cavallaro

2006-09-13, 7:04 pm

On 2006-09-13 11:15:34 -0400, perltcl@yahoo.com said:

> I've tried :
> (cons 1 (cons 2 (cons 3 4)))


(cons 1 (cons 2 (cons 3 (cons 4 ()))))

returns:

(1 2 3 4)

in other words, you can just enter the empty list as () directly
instead of using nil.

or just do:

(define nil ())

(cons 1 (cons 2 (cons 3 (cons 4 nil))))

returns:

(1 2 3 4)

perltcl@yahoo.com

2006-09-13, 7:04 pm


Raffael Cavallaro wrote:
> On 2006-09-13 11:15:34 -0400, perltcl@yahoo.com said:
>
>
> (cons 1 (cons 2 (cons 3 (cons 4 ()))))


only tinyscheme gives me the right result, while guile and scheme48
gives syntax error...

>
> returns:
>
> (1 2 3 4)
>
> in other words, you can just enter the empty list as () directly
> instead of using nil.
>
> or just do:
>
> (define nil ())
>
> (cons 1 (cons 2 (cons 3 (cons 4 nil))))
>
> returns:
>
> (1 2 3 4)


Matthias Blume

2006-09-13, 7:04 pm

perltcl@yahoo.com writes:

> Raffael Cavallaro wrote:
>
> only tinyscheme gives me the right result, while guile and scheme48
> gives syntax error...


() is not a valid Scheme expression. You need to quote the empty list.
Raffael Cavallaro

2006-09-13, 7:04 pm

On 2006-09-13 11:54:47 -0400, perltcl@yahoo.com said:

> only tinyscheme gives me the right result, while guile and scheme48
> gives syntax error...


I dont have either here, but you might also try (quote ()) or '() if
these two don't like the naked literal empty list.

2006-09-13, 7:04 pm

From: Matthias Blume <find@my.address.elsewhere>
Message-ID: <m13bavycr1.fsf@hana.uchicago.edu>
Organization: private
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)
Cancel-Lock: sha1:k0YQGWuMicUVxc0ftHbOxoq7baA=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 12
NNTP-Posting-Host: 128.135.191.139
X-Trace: news.uchicago.edu 1158163441 128.135.191.139 (Wed, 13 Sep 2006 11:04:01 CDT)
NNTP-Posting-Date: Wed, 13 Sep 2006 11:04:01 CDT
X-SessionID: wYVNg-778-45-144@news.uchicago.edu
X-Hash-Info: post-filter,v:1.4
X-Hash: ac7352d4 be17c274 d6780932 6526a643 43dee346
Date: Wed, 13 Sep 2006 11:04:02 -0500
Xref: number1.nntp.dca.giganews.com comp.lang.scheme:66632

Raffael Cavallaro <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com> writes:

> On 2006-09-13 11:54:47 -0400, perltcl@yahoo.com said:
>
>
> I dont have either here, but you might also try (quote ()) or '() if
> these two don't like the naked literal empty list.


Any Scheme implementation that accepts () as an expression is more
liberal than R5RS requires.
Eric Hanchrow

2006-09-13, 7:04 pm

If your "scheme" doesn't have "list", then it's not Scheme.
--
When it comes to electronic voting, most liberals are just plain
old-fashioned nuts.
-- Joe Andrew, former chairman of the Democratic National
Committee
Jussi Piitulainen

2006-09-13, 7:04 pm

perltcl@yahoo.com writes:
> Raffael Cavallaro wrote:
>
> only tinyscheme gives me the right result, while guile and scheme48
> gives syntax error...


(cons 1 (cons 2 (cons 3 (cons 4 ((lambda nil nil))))))

<duck />
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com