Handbook
Glossary
math-upgrade ( class1 class2 -- quot )
Vocabulary
generic
.
math
Inputs
class1
a
class
class2
a
class
Outputs
quot
a
quotation
with stack effect
( n n -- n n )
Word description
Outputs a quotation for upgrading numerical types. It takes two numbers on the stack, an instance of
class1
, and an instance of
class2
, and converts the one with the lower priority to the higher priority type.
Examples
USING: generic.math math kernel prettyprint ; fixnum bignum math-upgrade .
[ [ >bignum ] dip ]
Definition
USING:
generic.math.private
kernel
sequences
;
IN:
generic.math
:
math-upgrade
( class1 class2 -- quot )
[
math-class-max
]
2keep
[
(math-upgrade)
]
bi-curry@
bi
[
dup
empty?
[
[
dip
]
curry
]
unless
]
dip
[
]
append-as
;