math.combinators: fix help-lint errors.

db4
John Benediktsson 2013-05-06 08:34:32 -07:00
parent 5ccfb83a4d
commit a3cf0d70ba
3 changed files with 26 additions and 27 deletions

View File

@ -1,24 +1,18 @@
USING: arrays help.markup help.syntax math USING: help.markup help.syntax math ;
sequences.private vectors strings kernel math.order layouts
quotations generic.single ;
IN: math.combinators IN: math.combinators
HELP: when-negative HELP: when-negative
{ $values { $values { "n" real } { "true" "the first quotation of an " { $link if-negative } } }
{ "n" "an integer" } { "true" "a quotation" } { "m" "an integer" } } { $description "When " { $snippet "n" } " is negative, calls the " { $snippet "true" } " quotation with " { $snippet "n" } "." }
{ $description "When the n value is negative, calls the true quotation. The n value is passed to the quotation." } { $examples
{ $examples "The following two lines are equivalent." { $example "USING: math math.combinators prettyprint ;" "-3 [ 1 + ] when-negative ." "-2" }
{ $example "-1 [ 1 + ] when-negative\n-1 dup 0 < [ 1 + ] when" { $example "USING: math math.combinators prettyprint ;" "3.5 [ 1 + ] when-negative ." "3.5" }
"0\n0"
}
} ; } ;
HELP: when-positive HELP: when-positive
{ $values { $values { "n" real } { "true" "the first quotation of an " { $link if-positive } } }
{ "n" "an integer" } { "true" "a quotation" } { "m" "an integer" } } { $description "When " { $snippet "n" } " is positive, calls the " { $snippet "true" } " quotation with " { $snippet "n" } "." }
{ $description "When the n value is positive, calls the true quotation. The n value is passed to the quotation." } { $examples
{ $examples "The following two lines are equivalent." { $example "USING: math math.combinators prettyprint ;" "1.5 [ 1 + ] when-positive ." "2.5" }
{ $example "1 [ 1 + ] when-positive\n1 dup 0 > [ 1 + ] when" { $example "USING: math math.combinators prettyprint ;" "-1 [ 1 + ] when-positive ." "-1" }
"2\n2" } ;
}
} ;

View File

@ -1,7 +1,6 @@
! Copyright (C) 2013 Loryn Jenkins. ! Copyright (C) 2013 Loryn Jenkins.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.combinators USING: kernel math math.combinators tools.test ;
tools.test ;
IN: math.combinators.tests IN: math.combinators.tests
[ 0 ] [ -3 [ drop 0 ] when-negative ] unit-test [ 0 ] [ -3 [ drop 0 ] when-negative ] unit-test
@ -10,4 +9,4 @@ IN: math.combinators.tests
[ 0 ] [ 3 [ drop 0 ] when-positive ] unit-test [ 0 ] [ 3 [ drop 0 ] when-positive ] unit-test
[ 4 ] [ 3 [ 1 + ] when-positive ] unit-test [ 4 ] [ 3 [ 1 + ] when-positive ] unit-test
[ -2 ] [ -2 [ 0 ] when-positive ] unit-test [ -2 ] [ -2 [ 0 ] when-positive ] unit-test

View File

@ -1,10 +1,16 @@
! Copyright (C) 2013 Loryn Jenkins. ! Copyright (C) 2013 Loryn Jenkins.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: kernel math fry ; USING: kernel math ;
IN: math.combinators IN: math.combinators
: when-negative ( ..n true: ( ..a -- ..b ) -- ..m ) : if-negative ( ..a n true: ( ..a n -- ..b ) false: ( ..a n -- ..b ) -- ..b )
'[ _ dup 0 < [ @ ] when ] call ; inline [ dup 0 < ] 2dip if ; inline
: when-positive ( ..n true: ( ..a -- ..b ) -- ..m ) : if-positive ( ..a n true: ( ..a n -- ..b ) false: ( ..a n -- ..b ) -- ..b )
'[ _ dup 0 > [ @ ] when ] call ; inline [ dup 0 > ] 2dip if ; inline
: when-negative ( ..a n true: ( ..a n -- ..b ) -- ..b )
[ ] if-negative ; inline
: when-positive ( ..a n true: ( ..a n -- ..b ) -- ..b )
[ ] if-positive ; inline