Berkeley's "CS 61A Lecture 8: UI Recursion and Iteration III" says that null? checks if the list is empty and empty? checks if the list is empty or the word is empty? The lecturer also goes on to say (null? empty) will return false. But DrScheme doesnt mind at all.
What is the difference between null? and empty? in Scheme?
An empty collection isn't the same as null . An empty collection is actually a collection, but there aren't any elements in it yet. null means no collection exists at all.
The dot symbol is displayed when you build a cons -pair or a list which is not proper (meaning: it doesn't end with the empty list).
No difference (in my favorite dialect -- empty?
is not in the standard, and it's too long since I used any different dialect;)...! Quoting PLT scheme docs:
(null? v) → boolean?
v : any/c
Returns #t if v is the empty list, #f otherwise.
and
(empty? v) → boolean?
v : any/c
The same as (null? v).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With