2016-04-04 21:34 GMT+02:00 rom cgb <romainbeck...@gmail.com>: > Hi, > > Trying to use eof in a case expression but it doesn't work. > > For example > > (define (test x) > (case x > [(eof) eof] > [else "else"])) > > > (test eof) will then evaluate to "else" despite (equal? eof eof) > evaluating to #t. > > Why ?
The (eof) clause in case is a list of datums. That means case will taste for the symbol eof and not the end of file object. (case 'eof [(eof) 42]) ; 42 (case eof [(eof) 42] [else #f]) ; #f Instead use cond (cond [(eof-object? x) ...] [else #f]) /Jens Axel > > > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- Jens Axel Søgaard -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.