For languages that don’t include a dedicated Boolean type, what strategy is commonly used for representing Boolean values? Describe two advantages in having a dedicated Boolean type.
For languages that don’t include a dedicated Boolean type, what strategy is commonly used for representing Boolean values? Describe two advantages in having a dedicated Boolean type.
The language Lisp 1958 never had a form-in Boolean data type. Instead, conditional constructs like cond assume that the logical value false is expressed by the empty list , which is described to be the same as the special atom nil or NIL; where all other s-expression is interpreted as true. For convenience, the near contemporary dialects of Lisp predefine the atom t to score value t, so this t can be used as a mnemonic notation for true.
This method can be used as a Boolean value in most Lisp dialects has been retained. Many scripting languages, including those with a distinct Boolean form or Boolean values, have adopted common Lisp, Scheme, Emacs Lisp, and similar models; however which values are interpreted as false and which are true differ from language communication to language. For instance, the false value in Scheme is an atom separate from the empty list, so the latter is interpreted as true.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps