[plt-scheme] Match expression with underscore

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Sat Apr 14 09:27:22 EDT 2007

(quote _) works for me:

(require (lib "plt-match.ss"))

(match '_
  ('_ 2))

(match 'b
  ('_ 2)
  (else 1))

=>

Welcome to DrScheme, version 360.
Language: Textual (MzScheme, includes R5RS).
2
1


----- Original Message ----- 
From: "Jens Axel Søgaard" <jensaxel at soegaard.net>
To: "PLT-list" <plt-scheme at list.cs.brown.edu>
Sent: Saturday, April 14, 2007 6:36 AM
Subject: [plt-scheme] Match expression with underscore


> Hi all,
> 
> In match an underscore matches anything. But how
> do I match an underscore?
> 
> 
>   Welcome to DrScheme, version 369.8-svn17feb2007 [3m].
>   Language: Pretty Big (includes MrEd and Advanced Student).
> 
>   > (match '_
>       [('_) 2])
>   match: no matching clause for _
> 
> Is it a bug, or is it intentional?
> 
> 
> For now I am using this workaround:
> 
>   > (define (underscore? o)
>       (eq? o '_))
>   > (match '_
>       [(? underscore? s) s])
>   _
> 
> -- 
> Jens Axel Søgaard
> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>

Posted on the users mailing list.