I was wondering what (cons? list-name) does. Does it just check that list-name is not a non-empty list? Is it just like the opposite of (empty? list-name)? If so, then is it not better to just say (empty? list-name) and then say else instead of cons?? For example:
(define (f list-name)
(cond
[(empty? list-name) empty]
[(cons? list-name) "do something]))
cons?checks whether the value is aconscell, e.g., something that's(cons foo bar)for somefooandbar.If
(cons? a)is true, then it is safe to usecarandcdrona.This isn't the opposite of
empty?sinceempty?is true if and only if the argument is the empty list, so(empty? 1) == (cons? 1) == #f.Sidenote: Please don't put
PLEASE HELP!!or similar in your question titles, everyone here is happy to help, but it's a bit obnoxious to read. Just something to keep in mind in the future. Welcome to SO.