{"id":41272,"date":"2021-03-31T04:22:16","date_gmt":"2021-03-31T04:22:16","guid":{"rendered":"https:\/\/www.oracletutoring.ca\/blog\/?p=41272"},"modified":"2021-03-31T04:24:22","modified_gmt":"2021-03-31T04:24:22","slug":"computer-science-lisp-ideas-about-true-and-false","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/computer-science-lisp-ideas-about-true-and-false\/","title":{"rendered":"Computer science: LISP: ideas about true and false"},"content":{"rendered":"\n<h2>Self-tutoring about Comp Sci: the tutor mentions true and false in LISP.<\/h2>\n<p>\nAn interesting aspect of every computer language is what it thinks of as &#8220;true&#8221; vs &#8220;false&#8221;. Many languages think 0 is false, while any other declared value, such as &#8220;hello&#8221; or even -1, is true. JavaScript, for instance, seems to see it that way, in my experience.<\/p>\n<p><em>Note herein the difference between 0 (zero) and () (empty brackets), since they may look almost the same on some browsers.<\/em><\/p>\n<p>\nLISP, however, seems to see it differently: anything defined as something other than nil or () is true, even if it&#8217;s defined as 0. LISP doesn&#8217;t have false; just nil. The only way to attain nil value is to be declared nil or () or else to arrive there by calculation.<\/p>\n<p>In LISP, as in some other computer languages, an undefined (or undeclared) variable isn&#8217;t nil (or false); rather, the interpreter will complain when it encounters one.<\/p>\n<p>So, a main thought: in LISP, (or 0 1) evaluates to 0, which is &#8220;not false&#8221;. However, (or nil) evaluates to nil, which is false, in LISP.<\/p>\n<p>Surprising, eh?<\/p>\n<p>Source:<\/p>\n<p><a href=\"https:\/\/www.cs.cmu.edu\/Groups\/AI\/html\/cltl\/clm\/node9.html\">cs.cmu.edu<\/a><\/p>\nJack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.\n","protected":false},"excerpt":{"rendered":"<p>Self-tutoring about Comp Sci: the tutor mentions true and false in LISP. An interesting aspect of every computer language is what it thinks of as &#8220;true&#8221; vs &#8220;false&#8221;. Many languages think 0 is false, while any other declared value, such &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/computer-science-lisp-ideas-about-true-and-false\/\"> <span class=\"screen-reader-text\">Computer science: LISP: ideas about true and false<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[],"class_list":["post-41272","post","type-post","status-publish","format-standard","hentry","category-computer-science"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=41272"}],"version-history":[{"count":9,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41272\/revisions"}],"predecessor-version":[{"id":41281,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/41272\/revisions\/41281"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=41272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=41272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=41272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}