when-negative ( ..a n quot: ( ..a n -- ..b ) -- ..b ) (original) (raw)

Vocabulary
math.combinators

Inputs

n a real
quot the first quotation of an if-negative

Outputs
None

Word description
When n is negative, calls the quotation with n.

Examples

USING: math math.combinators prettyprint ; -3 [ 1 + ] when-negative .
-2

USING: math math.combinators prettyprint ; 3.5 [ 1 + ] when-negative .
3.5

Definition

IN: math.combinators

: when-negative ( ..a n quot: ( ..a n -- ..b ) -- ..b )
[ ] if-negative ; inline