Add round-to function
This commit is contained in:
parent
f4d29094c9
commit
19a7b4a287
@ -5,7 +5,7 @@
|
|||||||
(import (srfi srfi-1)
|
(import (srfi srfi-1)
|
||||||
(srfi srfi-60))
|
(srfi srfi-60))
|
||||||
|
|
||||||
(export log2 clog2
|
(export log2 clog2 round-to
|
||||||
one? power-of-two?
|
one? power-of-two?
|
||||||
curry curry-r
|
curry curry-r
|
||||||
transpose
|
transpose
|
||||||
@ -36,6 +36,11 @@
|
|||||||
;;; Check for (x == 1)
|
;;; Check for (x == 1)
|
||||||
(define (one? x) (= x 1))
|
(define (one? x) (= x 1))
|
||||||
|
|
||||||
|
;;; Round to the 'n' decimal place
|
||||||
|
(define (round-to n num)
|
||||||
|
(let ((k (expt 10 n)))
|
||||||
|
(/ (round (* num k)) k)))
|
||||||
|
|
||||||
;;; Currying
|
;;; Currying
|
||||||
;;; Example: ((curry-r f 1) 2 3) -> (f 1 2 3)
|
;;; Example: ((curry-r f 1) 2 3) -> (f 1 2 3)
|
||||||
(define (curry f . args)
|
(define (curry f . args)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user