X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=tt.rkt;h=409ef51296b8e88fc1d997924179e6d6ab66b934;hb=6df41218feef6f9a5fb726a49abfbdf4f80b5030;hp=b11364f4aaf3d16b9b5db273dfdb803fd435a598;hpb=24c6a76b401882f7c263d07efdf73109fa483128;p=tt.git diff --git a/tt.rkt b/tt.rkt index b11364f..409ef51 100644 --- a/tt.rkt +++ b/tt.rkt @@ -34,6 +34,9 @@ ; - d | download ; - u | upload ; - calls user-configured command to upload user's own feed file to their server +; +; Looks like a better CLI parser than "racket/cmdline": +; https://docs.racket-lang.org/natural-cli/ #lang racket @@ -43,10 +46,14 @@ (require http-client) (require rfc3339-old) +(module+ test + (require rackunit)) + (struct msg (ts_epoch ts_rfc3339 nick uri text)) (struct feed (nick uri)) (define (concurrent-filter-map num_workers f xs) + ; TODO preserve order of elements OR communicate that reorder is expected ; TODO switch from mailboxes to channels (define (make-worker id f) (define parent (current-thread)) @@ -80,6 +87,15 @@ (for-each thread-wait threads) results) +(module+ test + (define n-workers 10) + (define given (list + (λ (x) (if (even? x) x #f)) + (range 11))) + (check-equal? + (sort (apply concurrent-filter-map (cons n-workers given)) <) + (sort (apply filter-map given ) <))) + (define (msg-print out-format odd msg) (printf (match out-format