factor/basis/combinators/short-circuit/short-circuit-docs.factor

69 lines
4.0 KiB
Factor
Raw Normal View History

2008-09-15 01:03:53 -04:00
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: help.markup help.syntax io.streams.string quotations
2009-07-18 07:32:57 -04:00
math kernel ;
2008-09-15 01:03:53 -04:00
IN: combinators.short-circuit
HELP: 0&&
2009-09-11 18:59:04 -04:00
{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( -- ? )" } } { "?" "the result of the last quotation, or " { $link f } } }
2009-07-18 07:32:57 -04:00
{ $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
2008-09-15 01:03:53 -04:00
HELP: 0||
2009-09-11 18:59:04 -04:00
{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( -- ? )" } } { "?" "the first true result, or " { $link f } } }
2009-07-18 07:32:57 -04:00
{ $description "If every quotation in the sequence outputs " { $link f } ", outputs " { $link f } ", otherwise outputs the result of the first quotation that did not yield " { $link f } "." } ;
2008-09-15 01:03:53 -04:00
HELP: 1&&
2009-09-11 18:59:04 -04:00
{ $values { "obj" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj -- ? )" } } { "?" "the result of the last quotation, or " { $link f } } }
2009-07-18 07:32:57 -04:00
{ $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
2008-09-15 01:03:53 -04:00
HELP: 1||
2009-09-11 18:59:04 -04:00
{ $values { "obj" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj -- ? )" } } { "?" "the first true result, or " { $link f } } }
2008-09-15 01:03:53 -04:00
{ $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same element from the datastack and must return a boolean." } ;
HELP: 2&&
2009-09-11 18:59:04 -04:00
{ $values { "obj1" object } { "obj2" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 -- ? )" } } { "?" "the result of the last quotation, or " { $link f } } }
2009-07-18 07:32:57 -04:00
{ $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
2008-09-15 01:03:53 -04:00
HELP: 2||
2009-09-11 18:59:04 -04:00
{ $values { "obj1" object } { "obj2" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 -- ? )" } } { "?" "the first true result, or " { $link f } } }
2008-09-15 01:03:53 -04:00
{ $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same two elements from the datastack and must return a boolean." } ;
HELP: 3&&
2009-09-11 18:59:04 -04:00
{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 obj3 -- ? )" } } { "?" "the result of the last quotation, or " { $link f } } }
2009-07-18 07:32:57 -04:00
{ $description "If every quotation in the sequence outputs a true value, outputs the result of the last quotation, otherwise outputs " { $link f } "." } ;
2008-09-15 01:03:53 -04:00
HELP: 3||
2009-09-11 18:59:04 -04:00
{ $values { "obj1" object } { "obj2" object } { "obj3" object } { "quots" "a sequence of quotations with stack effect " { $snippet "( obj1 obj2 obj3 -- ? )" } } { "?" "the first true result, or " { $link f } } }
2008-09-15 01:03:53 -04:00
{ $description "Returns true if any quotation in the sequence returns true. Each quotation takes the same three elements from the datastack and must return a boolean." } ;
2008-11-21 05:36:18 -05:00
HELP: n&&
2008-09-15 01:03:53 -04:00
{ $values
2009-07-18 07:32:57 -04:00
{ "quots" "a sequence of quotations" } { "n" integer }
2008-09-15 01:03:53 -04:00
{ "quot" quotation } }
2009-07-18 07:32:57 -04:00
{ $description "A macro that rewrites the code to pass " { $snippet "n" } " parameters from the stack to each quotation, evaluating the result in the same manner as " { $link 0&& } "." } ;
2008-09-15 01:03:53 -04:00
2008-11-21 05:36:18 -05:00
HELP: n||
2008-09-15 01:03:53 -04:00
{ $values
2008-11-21 05:36:18 -05:00
{ "quots" "a sequence of quotations" } { "n" integer }
2008-09-15 01:03:53 -04:00
{ "quot" quotation } }
{ $description "A macro that rewrites the code to pass " { $snippet "n" } " parameters from the stack to each OR quotation." } ;
2008-09-15 01:03:53 -04:00
2008-09-23 17:14:34 -04:00
ARTICLE: "combinators.short-circuit" "Short-circuit combinators"
2008-09-15 01:03:53 -04:00
"The " { $vocab-link "combinators.short-circuit" } " vocabulary stops a computation early once a condition is met." $nl
"AND combinators:"
{ $subsection 0&& }
{ $subsection 1&& }
{ $subsection 2&& }
{ $subsection 3&& }
"OR combinators:"
{ $subsection 0|| }
{ $subsection 1|| }
{ $subsection 2|| }
{ $subsection 3|| }
"Generalized combinators:"
2008-11-21 05:36:18 -05:00
{ $subsection n&& }
{ $subsection n|| }
2008-09-15 01:03:53 -04:00
;
ABOUT: "combinators.short-circuit"