Add TR support for gcd and lcm on rationals.

original commit: b5d393d9393d59a4d31b2f8c4538433b40a3e489
This commit is contained in:
Vincent St-Amour 2011-12-08 17:03:44 -05:00
parent 4c8e90b8ac
commit 10d89c8f8f
2 changed files with 15 additions and 1 deletions

View File

@ -172,6 +172,16 @@
(tc-e (- -23524623547234734568) -PosInt)
(tc-e (- 241.3) -NegFlonum)
(tc-e (- -24.3) -PosFlonum)
(tc-e (gcd 1/2) -PosRat)
(tc-e (gcd 3 1/2) -PosRat)
(tc-e (gcd (ann 3 Integer) 1/2) -NonNegRat)
(tc-e (gcd (ann 3 Integer) -1/2) -NonNegRat)
(tc-e (lcm 1/2) -PosRat)
(tc-e (lcm 3 1/2) -PosRat)
(tc-e (lcm (ann 3 Integer) 1/2) -NonNegRat)
(tc-e (lcm (ann 3 Integer) -1/2) -NonNegRat)
[tc-e/t (lambda: () 3) (t:-> -PosByte : -true-lfilter)]
[tc-e/t (lambda: ([x : Number]) 3) (t:-> N -PosByte : -true-lfilter)]
[tc-e/t (lambda: ([x : Number] [y : Boolean]) 3) (t:-> N B -PosByte : -true-lfilter)]

View File

@ -1677,7 +1677,7 @@
(map binop (list -Flonum -SingleFlonum -InexactReal -Real)))]
[gcd (from-cases (varop -Zero)
(varop -One)
(varop-1+ -One)
(varop-1+ -PosByte)
(varop -Byte)
(varop-1+ -PosIndex)
@ -1686,6 +1686,8 @@
(varop -Fixnum -NonNegFixnum)
(varop-1+ -PosInt)
(varop -Int -Nat)
(varop-1+ -PosRat)
(varop -Rat -NonNegRat)
;; also supports inexact integers
(varop-1+ -PosFlonum)
(commutative-case -PosFlonum -PosReal -PosFlonum)
@ -1712,6 +1714,8 @@
(binop -Byte -Index)
(varop (Un -PosInt -NegInt) -PosInt)
(varop -Int -Nat)
(varop (Un -PosRat -NegRat) -PosRat)
(varop -Rat -NonNegRat)
;; also supports inexact integers
(commutative-case -FlonumZero -Real -FlonumPosZero)
(commutative-case -SingleFlonumZero -Real -SingleFlonumPosZero)