[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] Suggestion for the ports unit: port-pipe
From: |
Felix |
Subject: |
Re: [Chicken-hackers] Suggestion for the ports unit: port-pipe |
Date: |
Mon, 09 Aug 2010 05:47:28 +0200 (CEST) |
From: Moritz Heidkamp <address@hidden>
Subject: [Chicken-hackers] Suggestion for the ports unit: port-pipe
Date: Mon, 09 Aug 2010 04:02:19 +0200
> Dear Chickenados,
>
> I frequently find myself wanting/implementing a procedure which I shall
> call `port-pipe'. As the name suggests, its purpose is piping data from
> one port to another. As I find it very handy and general-purposey, I
> propose it for inclusion in the ports unit. Without further ado, here is
> the procedure:
>
> (define (port-pipe #!key (from (current-input-port)) (to
> (current-output-port)) (read read-char) (write write-char))
> (with-output-to-port to
> (lambda ()
> (with-input-from-port from
> (lambda ()
> (port-for-each write read))))))
>
I'd call it `port-copy'.
cheers,
felix