Merge Joe Groff's booleans vocab into kernel
parent
e6a6ac035b
commit
ba40acda28
|
@ -1,7 +0,0 @@
|
|||
! (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." } ;
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
! (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
|
|
@ -1,5 +0,0 @@
|
|||
! (c)2009 Joe Groff, see bsd license
|
||||
USING: kernel ;
|
||||
IN: booleans
|
||||
|
||||
UNION: boolean POSTPONE: t POSTPONE: f ;
|
|
@ -198,6 +198,8 @@ ARTICLE: "booleans" "Booleans"
|
|||
"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 }
|
||||
|
|
|
@ -129,6 +129,9 @@ HELP: ?
|
|||
{ $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 } "." } ;
|
||||
|
|
|
@ -176,12 +176,14 @@ PRIVATE>
|
|||
: 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
|
||||
|
|
Loading…
Reference in New Issue