mardi 30 mai 2017

If statement with then clause (LISP)

So I'm trying to teach myself lisp, I'm currently using this site as a reference: http://ift.tt/2qz4Ciy

I don't quite understand why the then clause is executed, despite the fact that the if clause is false?

(setq a 10)
(if (> a 20)
   then (format t "~% a is less than 20"))
(format t "~% value of a is ~d " a)

The output is:

a is less than 20
value of a is 10 

Does the then clause just always execute, even when the if statement is false? (which in this case it is).

Any help would be appreciated, also sorry if my terminology is totally incorrect I'm still new to Lisp!

Aucun commentaire:

Enregistrer un commentaire