Oh! More fancy that what I expected (link
https://github.com/racket/racket/blob/master/racket/collects/racket/private/case.rkt
)
It separates the items by type, and to trigger most of the special
cases it requires at lest 10/12 of each.
Another example, with many special cases:
#lang racket
(sy
Really this is not the best example either. I guess best to look at
the source, which is in racket/private/case and, according to a
comment in the top of the file, is based on Clinger's paper, "Rapid
Case Dispatch in Scheme".
Robby
On Fri, Jun 3, 2016 at 6:35 PM, Robby Findler
wrote:
> I think
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 a
On Sat, Jun 4, 2016 at 1:23 AM, Gustavo Massaccesi wrote:
> > [...] I saw in the docs that case specifically mentions it can
> distribute in log(n) time [...]
> 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 implementat
> [...] 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
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,
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
> wrote:
>
> I have been recently using match a lot and I w
match is far more expressive than case. Think of
> (match 3 [(? even? x) (+ x 1)][(? odd? x) (- x 1)])
But of course you’re paying for in terms of run-time cost.
Engineering is a trade-off game.
> On Jun 3, 2016, at 10:10 AM, Gerald Pipes
> wrote:
>
> I have been recently using match a
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
9 matches
Mail list logo