Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lisp if not nil

Tags:

People also ask

Is nil a symbol in Lisp?

An explanation of nil In Emacs Lisp, the symbol nil has two meanings. First, it means the empty list. Second, it means false and is the value returned when a true-or-false-test tests false. nil can be written as an empty list, () , or as nil .

Is an empty list nil in Lisp?

The empty list is also known as nil, it's written representation is either the literal nil or the empty list: ().

What is false Lisp?

Lisp includes a number of functions that give a true or false answer - they are called predicates, and often (but not always) have names ending with p. In Lisp the convention is that nil, or the empty list, means false, and anything else means true.

How do I check if a list is empty in scheme?

Scheme provides a procedure, null? to check whether a value is (a pointer to) the empty list, i.e., a null pointer. For example, (null? foo) returns #t if the value of the variable foo is the empty list, and #f otherwise.


I am so sorry for having to ask this question but I'm trying to do a simple if statement that checks if a variable is nil or not.

(defun test (input)
  (let ((testvar (first input)))
   (if (not nil testvar)
    (do this)
    (do that))))

Could anyone explain the proper syntax to me?


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!