Good idea. I'll look into that. Vincent
At Fri, 22 Apr 2011 17:09:51 -0400, Eli Barzilay wrote: > 40 minutes ago, Vincent St-Amour wrote: > > With this patch, assoc and member are implemented in Racket. They > > are currently implemented in C. I haven't measured the performance > > impact of the change, but I can do it if someone believes it's > > necessary. > > One way to make it fast is to have it bound to a macro so (member f l > eq?) expands to a `memq', and when used as a function have it dispatch > to `memq' if given `eq?'. Then, if the racket version is fast enough, > then you can do something similar to what `sort' does -- implement it > with a macro that generates the body, use the macro a few times to get > compiled versions of the function with `eq?' etc hard wired (and > therefore inlined), and then do the same kind of dispatch over the > results. One benefit of that is that you can use additional common > cases like `='. The implementation of `sort' does this with one more > trick that Matthew suggested: have the macro that generates the code > be local, so that there's no need to keep it in the compiled file. > > -- > ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: > http://barzilay.org/ Maze is Life! _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/dev