I think they need to be bigger, but case does have some smarts. Try
this one (add a `pretty-write` if you're running in cmd-line racket).

#lang racket
(syntax->datum
 (expand
  #'(case x
      [(1 2 3 4 5 6 7 8 9 10) 1]
      [(a b c d e f g h i j k l m n o p q r s t) 2])))


On Fri, Jun 3, 2016 at 6:23 PM, Gustavo Massaccesi <gust...@oma.org.ar> wrote:
>  > [...] I saw in the docs that case specifically mentions it can
> distribute in log(n) time [...]
>
> I think it's strange. I found the reference in
> https://docs.racket-lang.org/reference/case.html but it's very
> strange. Is it true???
>
> For example, I tried with
>
> ;---
> #lang racket
> (lambda (x)
>   (case x
>     [(1 "1" #"1" |1|) 1]
>     [(2 "2" #"2" |2|) 2]))
> (lambda (x)
>   (case x
>     [(1 3 5 7) 1]
>     [(2 4 6 8) 2]))
> ;---
>
> but both expand to a bunch of nested if, nothing fancy that may run in
> O(log(N)).
> (I don't expect that it has a smarter implementation for bigger N.)
>
> Gustavo
>
>
> On Fri, Jun 3, 2016 at 11:40 AM, Gerald Pipes
> <gerald_pi...@student.uml.edu> wrote:
>> On Friday, June 3, 2016 at 10:30:35 AM UTC-4, Jon Zeppieri wrote:
>>> There's rarely a good reason. If you were dispatching over a very large set 
>>> of constants -- fixnums or characters, in particular -- I'd expect better 
>>> performance from case. That's about it.
>>>
>>> > On Jun 3, 2016, at 10:10 AM, Gerald Pipes <gerald_pi...@student.uml.edu> 
>>> > wrote:
>>> >
>>> > I have been recently using match a lot and I was wondering what was the 
>>> > main benefit of using case instead of match?  It seems as though match 
>>> > has the distribution on a single val-exp except match allows for the 
>>> > pattern matching and case just uses equal?.
>>> >
>>> > --
>>> > 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.
>>
>> Yes, I saw in the docs that case specifically mentions it can distribute in 
>> log(n) time but for match there is no time mentioned. I assumed case's 
>> performance was better because of the performance omission of match. Does 
>> anyone know the actual performance of match?
>>
>> --
>> 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.
>
> --
> 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.

-- 
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.

Reply via email to