mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-04 03:36:34 +02:00
Placeholders for integer division
This commit is contained in:
parent
a0211b229a
commit
7747ca9da2
1 changed files with 28 additions and 1 deletions
|
@ -15,6 +15,14 @@
|
||||||
odd?
|
odd?
|
||||||
gcd
|
gcd
|
||||||
lcm
|
lcm
|
||||||
|
quotient
|
||||||
|
remainder
|
||||||
|
truncate-quotient
|
||||||
|
truncate-remainder
|
||||||
|
truncate/
|
||||||
|
floor-quotient
|
||||||
|
floor-remainder
|
||||||
|
floor/
|
||||||
call-with-current-continuation
|
call-with-current-continuation
|
||||||
call/cc
|
call/cc
|
||||||
call-with-values
|
call-with-values
|
||||||
|
@ -885,7 +893,6 @@
|
||||||
make_int(result, i % j);
|
make_int(result, i % j);
|
||||||
return_closcall1(data, k, &result);
|
return_closcall1(data, k, &result);
|
||||||
}")
|
}")
|
||||||
(define floor-remainder modulo)
|
|
||||||
(define (odd? num) (= (modulo num 2) 1))
|
(define (odd? num) (= (modulo num 2) 1))
|
||||||
(define (even? num) (= (modulo num 2) 0))
|
(define (even? num) (= (modulo num 2) 0))
|
||||||
(define (exact-integer? num)
|
(define (exact-integer? num)
|
||||||
|
@ -929,4 +936,24 @@
|
||||||
1
|
1
|
||||||
(foldl lcm/main (car nums) (cdr nums))))
|
(foldl lcm/main (car nums) (cdr nums))))
|
||||||
;; END gcd lcm
|
;; END gcd lcm
|
||||||
|
|
||||||
|
;; TODO: neither of these two are correct, they are just placeholders
|
||||||
|
(define quotient /)
|
||||||
|
(define remainder modulo)
|
||||||
|
|
||||||
|
(define truncate-quotient quotient)
|
||||||
|
(define truncate-remainder remainder)
|
||||||
|
(define (truncate/ n m)
|
||||||
|
(values (truncate-quotient n m) (truncate-remainder n m)))
|
||||||
|
|
||||||
|
(define (floor-quotient n m)
|
||||||
|
(let ((res (floor (/ n m))))
|
||||||
|
(if (and (exact? n) (exact? m))
|
||||||
|
(exact res)
|
||||||
|
res)))
|
||||||
|
;(define floor-remainder modulo)
|
||||||
|
(define (floor-remainder n m)
|
||||||
|
(- n (* m (floor-quotient n m))))
|
||||||
|
(define (floor/ n m)
|
||||||
|
(values (floor-quotient n m) (floor-remainder n m)))
|
||||||
))
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue