+++ /dev/null
-! (c)2009 Joe Groff, see bsd license
-USING: help.markup help.syntax ;
-IN: booleans
-
-HELP: boolean
-{ $class-description "A union of the " { $link POSTPONE: t } " and " { $link POSTPONE: f } " classes." } ;
-
+++ /dev/null
-! (c)2009 Joe Groff, see bsd license
-USING: booleans tools.test ;
-IN: booleans.tests
-
-[ t ] [ t boolean? ] unit-test
-[ t ] [ f boolean? ] unit-test
-[ f ] [ 1 boolean? ] unit-test
+++ /dev/null
-! (c)2009 Joe Groff, see bsd license
-USING: kernel ;
-IN: booleans
-
-UNION: boolean POSTPONE: t POSTPONE: f ;
"In Factor, any object that is not " { $link f } " has a true value, and " { $link f } " has a false value. The " { $link t } " object is the canonical true value."
{ $subsection f }
{ $subsection t }
+"A union class of the above:"
+{ $subsection boolean }
"There are some logical operations on booleans:"
{ $subsection >boolean }
{ $subsection not }
{ $values { "?" "a generalized boolean" } { "true" object } { "false" object } { "true/false" "one two input objects" } }
{ $description "Chooses between two values depending on the boolean value of " { $snippet "cond" } "." } ;
+HELP: boolean
+{ $class-description "A union of the " { $link POSTPONE: t } " and " { $link POSTPONE: f } " classes." } ;
+
HELP: >boolean
{ $values { "obj" "a generalized boolean" } { "?" "a boolean" } }
{ $description "Convert a generalized boolean into a boolean. That is, " { $link f } " retains its value, whereas anything else becomes " { $link t } "." } ;
: tri-curry@ ( x y z q -- p' q' r' ) [curry] tri@ ; inline
! Booleans
+UNION: boolean POSTPONE: t POSTPONE: f ;
+
+: >boolean ( obj -- ? ) [ t ] [ f ] if ; inline
+
: not ( obj -- ? ) [ f ] [ t ] if ; inline
: and ( obj1 obj2 -- ? ) over ? ; inline
-: >boolean ( obj -- ? ) [ t ] [ f ] if ; inline
-
: or ( obj1 obj2 -- ? ) dupd ? ; inline
: xor ( obj1 obj2 -- ? ) [ f swap ? ] when* ; inline