X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=src%2Fscheme-primitives.4th;h=ba48b9e365a0f99ae7af8a6e241eecabb3d2e9d0;hb=3055ae2e3d57ec91a4187a6c5cf8f05357d60810;hp=5ec154b5812c2754ea88e944b753a2193aeb3b3e;hpb=613b910f0ceb0ec0948a0e0595cd3e82086754cf;p=scheme.forth.jl.git diff --git a/src/scheme-primitives.4th b/src/scheme-primitives.4th index 5ec154b..ba48b9e 100644 --- a/src/scheme-primitives.4th +++ b/src/scheme-primitives.4th @@ -20,6 +20,10 @@ flonum-type istype? -rot 2drop boolean-type ; 1 make-fa-primitive flonum? +:noname ( args -- boolobj ) + ratnum-type istype? -rot 2drop boolean-type +; 1 make-fa-primitive ratnum? + :noname ( args -- boolobj ) character-type istype? -rot 2drop boolean-type ; 1 make-fa-primitive char? @@ -223,11 +227,9 @@ swap abs swap ; 1 make-fa-primitive fix:abs - -( Find the GCD of n1 and n2 where n2 < n1. ) -: gcd ( n1 n2 -- m ) - -; +:noname ( fixnum fixnum -- fixnum' ) + drop swap drop gcd fixnum-type +; 2 make-fa-primitive fix:gcd \ --- Flonums --- @@ -368,6 +370,17 @@ drop swap drop f/ fatan flonum-type ; 2 make-fa-primitive flo:atan2 +\ --- Rationals --- + +' make-rational 2 make-fa-primitive make-rational + +:noname ( ratnum -- fixnum ) + drop pair-type car +; 1 make-fa-primitive rat:numerator + +:noname ( ratnum -- fixnum ) + drop pair-type cdr +; 1 make-fa-primitive rat:denominator \ --- Conversion ---