math-method ( word class1 class2 -- quot ) - Factor Documentation

math-method ( word class1 class2 -- quot )


Vocabulary
generic .math

Inputs
word a generic
class1 a class
class2 a class


Outputs
quot a quotation


Word description
Generates a definition for word when the two inputs are instances of class1 and class2, respectively.

Examples
USING: generic.math math prettyprint ; \ + fixnum float math-method .
[ { fixnum float } declare [ >float ] dip M\ float + ]


Definition
USING: arrays generic generic.math.private kernel kernel.private
sequences ;

IN: generic.math

: math-method ( word class1 class2 -- quot )
2dup and [
[ 2array [ declare ] curry nip ] [ math-upgrade nip ]
[ math-class-max over nearest-class (math-method) ] 3tri
3append
] [ 2drop object-method ] if ;

AltStyle によって変換されたページ (->オリジナル) /