In article <4a8acf7f$1@news.povray.org>,
Daniel Bastos wrote:
>> In Haskell, we just say
>>
>> main = interact id
>>
>> ;-)
>
> That's right! I should copy that! ;)
#!/usr/bin/env mzscheme
(module cat scheme/base
(define (interact f)
(let ([ln (read-line)])
(if (not (eq? ln eof))
(and (display (f ln)) (newline) (interact f))
(exit))))
(define (id x) x)
(define (cat)
(interact id))
;main
(cat)
)
%printf 'my\nbeloved\ncat\n' | ./cat
my
beloved
cat
%
Post a reply to this message
|