and ( obj1 obj2 -- ? )

Factor handbook » The language » Booleans

Factor handbook » The language » Booleans

Prev: | not ( obj -- ? ) |

Next: | or ( obj1 obj2 -- ? ) |

Vocabulary

kernel

Inputs

Outputs

Word description

If both inputs are true, outputs obj2. otherwise outputs f.

Notes

This word implements boolean and, so applying it to integers will not yield useful results (all integers have a true value). Bitwise and is the bitand word.

Examples

Usually only the boolean value of the result is used, however you can also explicitly rely on the behavior that if both inputs are true, the second is output:

Definition

kernel

Inputs

obj1 | a generalized boolean |

obj2 | a generalized boolean |

Outputs

? | a generalized boolean |

Word description

If both inputs are true, outputs obj2. otherwise outputs f.

Notes

This word implements boolean and, so applying it to integers will not yield useful results (all integers have a true value). Bitwise and is the bitand word.

Examples

Usually only the boolean value of the result is used, however you can also explicitly rely on the behavior that if both inputs are true, the second is output:

USING: kernel prettyprint ;
t f and .

f

f

USING: kernel prettyprint ;
t 7 and .

7

7

USING: kernel prettyprint ;
"hi" 12.0 and .

12.0

12.0

Definition