Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,17 @@
(define (reader)
(for ([line (in-lines (open-input-file "input.txt"))])
(thread-send printer-thread line))
(thread-send printer-thread eof)
(printf "Number of lines: ~a\n" (thread-receive)))
(define (printer)
(thread-send reader-thread
(for/sum ([line (in-producer thread-receive eof)])
(displayln line)
1)))
(define printer-thread (thread printer))
(define reader-thread (thread reader))
(for-each thread-wait
(list printer-thread reader-thread))

View file

@ -0,0 +1,19 @@
(define (reader out-ch result-ch)
(for ([line (in-lines (open-input-file "input.txt"))])
(channel-put out-ch line))
(channel-put out-ch eof)
(printf "Number of lines: ~a\n" (channel-get result-ch)))
(define (printer in-ch result-ch)
(channel-put result-ch
(for/sum ([line (in-producer channel-get eof in-ch)])
(displayln line)
1)))
(define lines-ch (make-channel))
(define result-ch (make-channel))
(define printer-thread (thread (lambda () (printer lines-ch result-ch))))
(define reader-thread (thread (lambda () (reader lines-ch result-ch))))
(for-each thread-wait
(list printer-thread reader-thread))