home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / language / scm / !Scm / slib / plottest < prev    next >
Encoding:
Text File  |  1992-11-14  |  638 b   |  29 lines

  1. (require 'charplot)
  2. (require 'random)
  3.  
  4. (define strophoid
  5.   (let ((l '()))
  6.     (do ((x -1.0 (+ x 0.05)))
  7.     ((> x 4.0))
  8.       (let* ((a (/ (- 2 x) (+ 2 x))))
  9.     (if (>= a 0.0)
  10.         (let* ((y (* x (sqrt a))))
  11.           (set! l (cons (cons x y) l))
  12.           (set! l (cons (cons x (- y)) l))))))
  13.     l))
  14.  
  15. (plot! strophoid "x" "y") (newline)
  16.  
  17. (define unif
  18.   (let* ((l 6)
  19.      (v (make-vector l)))
  20.     (do ((i (- l 1) (- i 1)))
  21.     ((negative? i))
  22.       (vector-set! v i (cons i 0)))
  23.     (do ((i 24 (- i 1))
  24.      (r (random l) (random l)))
  25.     ((zero? i) (vector->list v))
  26.       (set-cdr! (vector-ref v r) (+ 1 (cdr (vector-ref v r)))))))
  27.  
  28. (plot! unif "n" "occur")
  29.