Compare commits
No commits in common. "19a7b4a287be6556f3a3de4cc7daa7edace92588" and "f5977e41e1a267410b16399db6a7fa66d36de411" have entirely different histories.
19a7b4a287
...
f5977e41e1
@ -5,7 +5,7 @@
|
|||||||
(import (srfi srfi-1)
|
(import (srfi srfi-1)
|
||||||
(srfi srfi-60))
|
(srfi srfi-60))
|
||||||
|
|
||||||
(export log2 clog2 round-to
|
(export log2 clog2
|
||||||
one? power-of-two?
|
one? power-of-two?
|
||||||
curry curry-r
|
curry curry-r
|
||||||
transpose
|
transpose
|
||||||
@ -36,11 +36,6 @@
|
|||||||
;;; 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)
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
;;;
|
;;;
|
||||||
;;; Remove redundant (zero range) constraints.
|
;;; Remove redundant (zero range) constraints.
|
||||||
;;; Limit the weight value in positive range
|
;;; Limit weight in range (0..1]
|
||||||
;;;
|
;;;
|
||||||
(define (clean-constraints constrs)
|
(define (clean-constraints constrs)
|
||||||
(remove (lambda (c)
|
(remove (lambda (c)
|
||||||
@ -20,11 +20,14 @@
|
|||||||
(map (lambda (c)
|
(map (lambda (c)
|
||||||
(let ((from (inexact->exact (round (car c))))
|
(let ((from (inexact->exact (round (car c))))
|
||||||
(to (inexact->exact (round (cadr c))))
|
(to (inexact->exact (round (cadr c))))
|
||||||
(w (let ((w (caddr c)))
|
(w (caddr c)))
|
||||||
(if (< w 0) 0 w))))
|
(let ((w (cond
|
||||||
|
((< w 0) 0)
|
||||||
|
((> w 1) 1)
|
||||||
|
(else w))))
|
||||||
(if (> from to)
|
(if (> from to)
|
||||||
(list to from w)
|
(list to from w)
|
||||||
(list from to w))))
|
(list from to w)))))
|
||||||
constrs)))
|
constrs)))
|
||||||
;;;
|
;;;
|
||||||
;;; Make constrained random number generator.
|
;;; Make constrained random number generator.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user