Boolean values: Difference between revisions

Content added Content deleted
(→‎{{header|Common Lisp}}: nitpickery, ext link, mention "symbol")
(added ocaml, standard ml)
Line 90:
if empty? "|| [print "empty] ; empty word
</lang>
 
=={{header|OCaml}}==
 
OCaml defines a built-in data type <code>bool</code>, which has exactly two members, represented by the keywords <code>true</code> and <code>false</code>:
 
<lang ocaml>type bool = false | true</lang>
 
In addition to all the functionality of any other OCaml algebraic data type (e.g. [[pattern matching]]), and the functionality of any other OCaml data type (e.g. comparisons <code>false = false</code>, <code>false < true</code>, etc.), <code>bool</code> is also used in the guards in pattern matching (“<code>when</code>”) and <code>if</code> and <code>while</code> syntaxes.
 
As with any other Ocaml data type, there are no automatic conversions of other types to bool.
 
=={{header|Perl}}==
Line 170 ⟶ 180:
 
Everything else (including the empty list, unlike Lisp) is true. The constant <tt>#t</tt> represents the canonical true value.
 
=={{header|Standard ML}}==
 
Standard ML defines a top-level data type <code>bool</code>, which has exactly two members, <code>true</code> and <code>false</code>:
 
<lang sml>datatype bool = false | true</lang>
 
In addition to all the functionality of any other Standard ML algebraic data type (e.g. [[pattern matching]], equality <code>false = false</code>), <code>bool</code> is also used in <code>if</code> and <code>while</code> syntaxes.
 
As with any other Standard ML data type, there are no automatic conversions of other types to bool.
 
=={{header|Tcl}}==