I just downloaded gambc40b9 (haven't even built it; Linux binaries seem to work), and I have some dumb questions about Gambit. I have a fair amount of DrScheme code, which runs very slow, and I'm a bit tired of PLT right now, although I profited a lot from their teaching approach. I thought I'd port to Gambit for a speed increase. So:
Mostly I'm doing mod 2 linear algebra. That is, all my numbers are either 0 or 1. Isn't there some way to take advantage of that?
Does Gambit have a case sensitive mode? I didn't see anything like this in the info files, but maybe there's an easy way to get it.
Has anyone worked out ports of various DrScheme things, such as the local construction? Here's one dumb example:
(define (merge-1 shortlist longlist less-than?) ;; (listof x)^2 (x x -> boolean) -> (listof x) ;; to merge a short list into a longer list, deleting repetitions, using less-than?. ;; (merge-1 '(4 8 9) '(1 2 3 5 6 7 9 10 11) <) => (1 2 3 4 5 6 7 8 10) (local ((define (phi a B X less-than?) ;; x (listof x)^2 (x x -> boolean) -> (listof x) ;; to send a X B to (x_1 ... x_r a (mu B (x_{r+1} ... ))) if x_r < a < x_{r+1} (if (empty? X) (cons a B) (let ([x_1 (first X)]) (if (equal? a x_1) (merge-1 B (rest X) less-than?) (if (less-than? a x_1) (cons a (merge-1 B X less-than?)) (cons x_1 (phi a B (rest X) less-than?)))))))) (if (empty? shortlist) longlist (phi (first shortlist) (rest shortlist) longlist less-than?))))
I could turn all my local's into letrec's of course. There's other DrScheme stuff I use, like their quicksort & mergesort, I imagine there's already (faster) Gambit versions of these
Afficher les réponses par date
Bill Richter wrote:
Has anyone worked out ports of various DrScheme things, such as the local construction?
Here is a syntax-rules macro for local:
(define-syntax local (syntax-rules (define) ((local defs . body) (letrec-syntax ((rev (syntax-rules () ((rev accum (x . rest) b) (rev (x . accum) rest b)) ((rev accum () b) (f () accum b)))) (f (syntax-rules () ((f accum ((define (var . spec) . e) . rest) b) (f ((var (lambda spec . e)) . accum) rest b)) ((f accum ((define var e) . rest) b) (f ((var e) . accum) rest b)) ((f accum () b) (letrec accum . b))))) (rev () defs body)))))
David
Just a note, gsc doesn't seem to support define-syntax and the like.
On Mon, 18 Oct 2004 00:26:34 -0400, David Van Horn dvanhorn@cs.uvm.edu wrote:
Bill Richter wrote:
Has anyone worked out ports of various DrScheme things, such as the local construction?
Here is a syntax-rules macro for local:
(define-syntax local
Eric Merritt cyberlync@gmail.com wrote:
Just a note, gsc doesn't seem to support define-syntax and the like.
But it does still support defmacro-style macros. Actually I thought that I read in the release notes that define-syntax was in 4.0?
david rush
I agree it does have a macro facility. I wasn't trying to say otherwise. Actually from the readme
-- The Gambit-C system conforms to the R4RS and IEEE Scheme standards. -- and -- - unhygienic macros --
These two together suggest that it doesn't. Not that it really needs it as long as it has defmacro-style macros. I suspect that if you really really wanted syntax-case and define-syntax you could write them with a defmacro style macro.
On a side note, I had nearly a million threads running last night, on a stock pc, before I started running into timeout issues. Gambit 4 is an awesome system.
Has anyone worked out ports of various DrScheme things, such as the local construction?
Here is a syntax-rules macro for local:
Thanks, David! Problem is, I'd have to learn syntax-rules... I built gambc40b9 last night, and another Drscheme question occurred to me:
Can Emacs look like the DrScheme editor? The Gambit info files say:
Gambit comes with the Emacs package `gambit.el' which provides a nice environment for running Gambit from within the Emacs editor.
and this sticks a number of gambit features into an *.scm file we read into Emacs. But I'd like more syntax highlighting, which I suppose involves font-locking, and mainly I'd like this DrScheme feature:
an expression is highlighted if the point is at either end of it.
I'm sure these are simple enough Emacs questions, but folks here may already know how to do this.
Hello!
On Mon, 18 Oct 2004, Bill Richter wrote:
Can Emacs look like the DrScheme editor? The Gambit info files say:
Gambit comes with the Emacs package `gambit.el' which provides a nice environment for running Gambit from within the Emacs editor.
and this sticks a number of gambit features into an *.scm file we read into Emacs. But I'd like more syntax highlighting, which I suppose involves font-locking, and mainly I'd like this DrScheme feature:
an expression is highlighted if the point is at either end of it.
Drop a look at:
http://www.neilvandyke.org/quack/
Best regards, Kirill.