made sinewave example work
This commit is contained in:
parent
be804df673
commit
fdfb5558f3
5 changed files with 31 additions and 10 deletions
21
rhs/rhs.rkt
21
rhs/rhs.rkt
|
@ -13,6 +13,7 @@ Licensed under GPL (2 or 3? FIXME)
|
||||||
|
|
||||||
|#
|
|#
|
||||||
|
|
||||||
|
(require rnrs)
|
||||||
|
|
||||||
(provide (all-defined-out))
|
(provide (all-defined-out))
|
||||||
|
|
||||||
|
@ -446,7 +447,8 @@ Licensed under GPL (2 or 3? FIXME)
|
||||||
(lookup x (tail l))))))
|
(lookup x (tail l))))))
|
||||||
|
|
||||||
;; map :: (a -> b) -> [a] -> [b]
|
;; map :: (a -> b) -> [a] -> [b]
|
||||||
(define map1
|
(define map1 map)
|
||||||
|
#;(define map1
|
||||||
(lambda (f l)
|
(lambda (f l)
|
||||||
(if (null? l)
|
(if (null? l)
|
||||||
nil
|
nil
|
||||||
|
@ -749,7 +751,22 @@ Licensed under GPL (2 or 3? FIXME)
|
||||||
(cons (x) (replicate-m* (- i 1) x)))))
|
(cons (x) (replicate-m* (- i 1) x)))))
|
||||||
|
|
||||||
|
|
||||||
|
;; data/tree.scm ;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;; Tree a -> [a]
|
||||||
|
(define flatten
|
||||||
|
(letrec ((f (lambda (t r)
|
||||||
|
(cond ((null? t) r)
|
||||||
|
((pair? t) (f (head t) (f (tail t) r)))
|
||||||
|
(else (cons t r))))))
|
||||||
|
(lambda (t)
|
||||||
|
(f t nil))))
|
||||||
|
|
||||||
|
;; Tree a -> [[a]]
|
||||||
|
(define levels
|
||||||
|
(lambda (t)
|
||||||
|
(if (null? t)
|
||||||
|
nil
|
||||||
|
(let ((lr (partition* (compose not pair?) t)))
|
||||||
|
(cons (fst lr) (levels (concat (snd lr))))))))
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; [a] -> int -> [a]
|
;; [a] -> int -> [a]
|
||||||
(define extend
|
(define extend
|
||||||
(lambda (l n)
|
(lambda (l n)
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#lang racket
|
#lang racket
|
||||||
|
|
||||||
(require "../rhs/rhs.rkt" rnrs/bytevectors-6 rnrs/io/ports-6)
|
(require rnrs
|
||||||
|
"../rhs/rhs.rkt"
|
||||||
|
rnrs/bytevectors-6
|
||||||
|
rnrs/io/ports-6)
|
||||||
|
|
||||||
(provide (all-defined-out)
|
(provide (all-defined-out)
|
||||||
put-bytevector
|
put-bytevector
|
||||||
|
@ -62,3 +65,4 @@
|
||||||
(let ((v (make-bytevector k 0)))
|
(let ((v (make-bytevector k 0)))
|
||||||
(f v 0 n (endianness big))
|
(f v 0 n (endianness big))
|
||||||
v)))
|
v)))
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
(let* ((s (udp*-s u))
|
(let* ((s (udp*-s u))
|
||||||
(h (udp*-h u))
|
(h (udp*-h u))
|
||||||
(p (udp*-p u))
|
(p (udp*-p u))
|
||||||
(b (bytes 8192))
|
(b (make-bytes 8192))
|
||||||
(r (plt:sync/timeout 1.0 (plt:udp-receive!-evt s b))))
|
(r (plt:sync/timeout 1.0 (plt:udp-receive!-evt s b))))
|
||||||
(if r
|
(if r
|
||||||
(plt:subbytes b 0 (plt:car r))
|
(plt:subbytes b 0 (plt:car r))
|
||||||
|
@ -79,3 +79,4 @@
|
||||||
(lambda (fd)
|
(lambda (fd)
|
||||||
(close-input-port (tcp*-i fd))
|
(close-input-port (tcp*-i fd))
|
||||||
(close-output-port (tcp*-o fd))))
|
(close-output-port (tcp*-o fd))))
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
;; from transport.scm ;;;;;;;
|
;; from transport.scm ;;;;;;;
|
||||||
|
|
||||||
(require "bytevector.rkt"
|
(require rnrs
|
||||||
|
"bytevector.rkt"
|
||||||
"sosc.rkt"
|
"sosc.rkt"
|
||||||
"ip.rkt")
|
"ip.rkt")
|
||||||
|
|
||||||
|
@ -38,6 +39,6 @@
|
||||||
(let ((p (recv fd)))
|
(let ((p (recv fd)))
|
||||||
(cond
|
(cond
|
||||||
((not p) (error "wait" "timed out"))
|
((not p) (error "wait" "timed out"))
|
||||||
((not (string=? (first p) s)) (error "wait" "bad return packet" p s))
|
((not (string=? (car p) s)) (error "wait" "bad return packet" p s))
|
||||||
(else p)))))
|
(else p)))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue