Doesn't Matthias's version return #t and Matthew's returns void? (void
being preferable because it doesn't print anything?)

Robby

On Wed, May 26, 2010 at 9:27 AM, Matthias Felleisen
<matth...@ccs.neu.edu> wrote:
>
> On May 25, 2010, at 8:48 PM, Matthew Flatt wrote:
>
>> #lang racket
>> ;; Report each unique line from stdin:
>> (let ([saw (make-hash)])
>>   (for ([line (in-lines)])
>>     (unless (hash-ref saw line #f)
>>       (displayln line))
>>     (hash-set! saw line #t)))
>
> I would prefer to sacrifice one line to avoid the repetition of the test 
> (leakage). I doubt Perl and friends do that:
>
> #lang racket
> ;; Report each unique line from stdin:
> (define saw (make-hash))
> (for ([line (in-lines)])
>  (hash-ref saw line
>    (lambda ()
>      (displayln line)
>      (hash-set! saw line #t))))
>
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-dev
>
_________________________________________________
  For list-related administrative tasks:
  http://list.cs.brown.edu/mailman/listinfo/plt-dev

Reply via email to