math.combinators: fix help-lint errors.
parent
5ccfb83a4d
commit
a3cf0d70ba
|
@ -1,24 +1,18 @@
|
|||
USING: arrays help.markup help.syntax math
|
||||
sequences.private vectors strings kernel math.order layouts
|
||||
quotations generic.single ;
|
||||
USING: help.markup help.syntax math ;
|
||||
IN: math.combinators
|
||||
|
||||
HELP: when-negative
|
||||
{ $values
|
||||
{ "n" "an integer" } { "true" "a quotation" } { "m" "an integer" } }
|
||||
{ $description "When the n value is negative, calls the true quotation. The n value is passed to the quotation." }
|
||||
{ $examples "The following two lines are equivalent."
|
||||
{ $example "-1 [ 1 + ] when-negative\n-1 dup 0 < [ 1 + ] when"
|
||||
"0\n0"
|
||||
}
|
||||
{ $values { "n" real } { "true" "the first quotation of an " { $link if-negative } } }
|
||||
{ $description "When " { $snippet "n" } " is negative, calls the " { $snippet "true" } " quotation with " { $snippet "n" } "." }
|
||||
{ $examples
|
||||
{ $example "USING: math math.combinators prettyprint ;" "-3 [ 1 + ] when-negative ." "-2" }
|
||||
{ $example "USING: math math.combinators prettyprint ;" "3.5 [ 1 + ] when-negative ." "3.5" }
|
||||
} ;
|
||||
|
||||
HELP: when-positive
|
||||
{ $values
|
||||
{ "n" "an integer" } { "true" "a quotation" } { "m" "an integer" } }
|
||||
{ $description "When the n value is positive, calls the true quotation. The n value is passed to the quotation." }
|
||||
{ $examples "The following two lines are equivalent."
|
||||
{ $example "1 [ 1 + ] when-positive\n1 dup 0 > [ 1 + ] when"
|
||||
"2\n2"
|
||||
}
|
||||
} ;
|
||||
{ $values { "n" real } { "true" "the first quotation of an " { $link if-positive } } }
|
||||
{ $description "When " { $snippet "n" } " is positive, calls the " { $snippet "true" } " quotation with " { $snippet "n" } "." }
|
||||
{ $examples
|
||||
{ $example "USING: math math.combinators prettyprint ;" "1.5 [ 1 + ] when-positive ." "2.5" }
|
||||
{ $example "USING: math math.combinators prettyprint ;" "-1 [ 1 + ] when-positive ." "-1" }
|
||||
} ;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
! Copyright (C) 2013 Loryn Jenkins.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel math math.combinators
|
||||
tools.test ;
|
||||
USING: kernel math math.combinators tools.test ;
|
||||
IN: math.combinators.tests
|
||||
|
||||
[ 0 ] [ -3 [ drop 0 ] when-negative ] unit-test
|
||||
|
@ -10,4 +9,4 @@ IN: math.combinators.tests
|
|||
|
||||
[ 0 ] [ 3 [ drop 0 ] 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
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
! Copyright (C) 2013 Loryn Jenkins.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: kernel math fry ;
|
||||
USING: kernel math ;
|
||||
IN: math.combinators
|
||||
|
||||
: when-negative ( ..n true: ( ..a -- ..b ) -- ..m )
|
||||
'[ _ dup 0 < [ @ ] when ] call ; inline
|
||||
|
||||
: when-positive ( ..n true: ( ..a -- ..b ) -- ..m )
|
||||
'[ _ dup 0 > [ @ ] when ] call ; inline
|
||||
: if-negative ( ..a n true: ( ..a n -- ..b ) false: ( ..a n -- ..b ) -- ..b )
|
||||
[ dup 0 < ] 2dip if ; inline
|
||||
|
||||
: if-positive ( ..a n true: ( ..a n -- ..b ) false: ( ..a n -- ..b ) -- ..b )
|
||||
[ 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
|
||||
|
|
Loading…
Reference in New Issue