diff --git a/rhs/rhs.rkt b/rhs/rhs.rkt index d473142..a2ef23f 100644 --- a/rhs/rhs.rkt +++ b/rhs/rhs.rkt @@ -13,6 +13,7 @@ Licensed under GPL (2 or 3? FIXME) |# +(require rnrs) (provide (all-defined-out)) @@ -446,7 +447,8 @@ Licensed under GPL (2 or 3? FIXME) (lookup x (tail l)))))) ;; map :: (a -> b) -> [a] -> [b] -(define map1 +(define map1 map) +#;(define map1 (lambda (f l) (if (null? l) nil @@ -749,7 +751,22 @@ Licensed under GPL (2 or 3? FIXME) (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)))))))) diff --git a/rsc3/rsc3.rkt b/rsc3/rsc3.rkt index 8a6249a..199fe7c 100644 --- a/rsc3/rsc3.rkt +++ b/rsc3/rsc3.rkt @@ -12,8 +12,6 @@ ) - - ;; [a] -> int -> [a] (define extend (lambda (l n) diff --git a/sosc/bytevector.rkt b/sosc/bytevector.rkt index 461597d..843c942 100644 --- a/sosc/bytevector.rkt +++ b/sosc/bytevector.rkt @@ -1,6 +1,9 @@ #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) put-bytevector @@ -61,4 +64,5 @@ (lambda (f k n) (let ((v (make-bytevector k 0))) (f v 0 n (endianness big)) - v))) \ No newline at end of file + v))) + diff --git a/sosc/ip.rkt b/sosc/ip.rkt index be6fd3b..3306d7f 100644 --- a/sosc/ip.rkt +++ b/sosc/ip.rkt @@ -36,7 +36,7 @@ (let* ((s (udp*-s u)) (h (udp*-h u)) (p (udp*-p u)) - (b (bytes 8192)) + (b (make-bytes 8192)) (r (plt:sync/timeout 1.0 (plt:udp-receive!-evt s b)))) (if r (plt:subbytes b 0 (plt:car r)) @@ -78,4 +78,5 @@ (define tcp:close (lambda (fd) (close-input-port (tcp*-i fd)) - (close-output-port (tcp*-o fd)))) \ No newline at end of file + (close-output-port (tcp*-o fd)))) + diff --git a/sosc/transport.rkt b/sosc/transport.rkt index 29424ce..a6c9873 100644 --- a/sosc/transport.rkt +++ b/sosc/transport.rkt @@ -2,7 +2,8 @@ ;; from transport.scm ;;;;;;; -(require "bytevector.rkt" +(require rnrs + "bytevector.rkt" "sosc.rkt" "ip.rkt") @@ -38,6 +39,6 @@ (let ((p (recv fd))) (cond ((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)))))