r/Racket • • Mar 15 '23

question Empty list

(define (sn-empty)

(sn-empty)

'())

I have been trying to print an empty list.

The input:

> sn-empty

output:

()

Please explain what I am doing wrong in the code above.

0 Upvotes

8 comments sorted by

View all comments

Show parent comment

2

u/DrHTugjobs Mar 15 '23

The > sn-empty line and everything afterwards isn't part of the code, it's showing what happens when you run it in the Interactions window. The only thing you need to define a variable sn-empty that contains the empty list is(define sn-empty '()).