[racket] strange behaviour of a (match) form

From: Yuri Garmay (yuri.from.spb at gmail.com)
Date: Wed Oct 1 16:59:28 EDT 2014

Oh! Really. Thank you! Sorry, I am not experienced in Racket.


2014-10-02 0:56 GMT+04:00 Matthias Felleisen <matthias at ccs.neu.edu>:

>
> In this context, null is just a variable and it gets bound to what it
> matches:
>
> > Welcome to Racket v6.1.0.8.
> > > (match 'hello-world [null null])
> > 'hello-world
>
>
>
> On Oct 1, 2014, at 4:52 PM, Yuri Garmay <yuri.from.spb at gmail.com> wrote:
>
> > Hi, all
> >
> > Accidentally, I found out that null matchs in unexpected way (seems it
> matchs always)
> >
> > So,
> > (define (length-my list)
> >   (match list
> >     ['() 0]
> >     [(cons x xs)
> >      (+ 1
> >         (length-my xs))]
> >     [_ 'not-a-list]))
> > (length-my '(1 2 3 4))
> > >produces 4
> >
> > But
> > (define (length-my list)
> >   (match list
> >     [null 0]
> >     [(cons x xs)
> >      (+ 1
> >         (length-my xs))]
> >     [_ 'not-a-list]))
> > (length-my '(1 2 3 4))
> > >produces 0
> >
> > I also tried that:
> > (match '213423
> >   [null 0]
> >   [_ 1])
> > >produces 0
> > (match null
> >   ['213423 0]
> >   [_ 1])
> > >produces 1
> >
> > Is it a bug?
> >
> > I am using Racket 6.1
> >
> > --
> > Best regards,
> > Yuri
> >
> > ____________________
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>


-- 
Best regards,
Yuri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141002/3b9abcdb/attachment.html>

Posted on the users mailing list.