Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheme empty list expression

Tags:

scheme

I'm using http://rextester.com/runcode to do some scheme testing.

When I run

(define x (cons 3 null))
(write x)

it has an ERROR: Unbound variable: null.

How do I refer to an empty list in the above context?

like image 446
Frank Epps Avatar asked Oct 03 '22 22:10

Frank Epps


2 Answers

(define x (cons 3 '()))
(write x)

Alternatively, you can define null first:

(define null '())
(define x (cons 3 null))
(write x)
like image 106
Chris Jester-Young Avatar answered Oct 24 '22 10:10

Chris Jester-Young


In scheme, the empty list is (), not null. In other lisps it is also called nil.

like image 1
Terje D. Avatar answered Oct 24 '22 09:10

Terje D.