[plt-scheme] importing into mzscheme
Roy Lowrance wrote:
> I am trying to uset set-car! and have figured out that I need to
> import (rnrs mutable-pairs (6)):
> http://docs.plt-scheme.org/r6rs-lib-std/r6rs-lib-Z-H-18.html#node_idx_1276
>
> But I can't get the import statement to work. My code is:
> (import (rnrs mutable-pairs (6)))
> (define a-list '(a b c))
> (set-car! a-list 'x)
> (display a-list)
>
> I start mzscheme and (load "the-file.scm") and receive an error message:
> import: misuse of unit keyword in: (import (rnrs mutable-pairs (6)))
>
> What's the secret to getting this to work?
There is no `load' in R6RS. Do you really want to write programs in
R6RS, or do you just want to use mutable pairs within the full-fledged
PLT Scheme language?
Assuming the former, you can do this:
$ cat the-file.scm
#!r6rs
(import (rnrs)
(rnrs mutable-pairs (6)))
(define a-list '(a b c))
(set-car! a-list 'x)
(display a-list)
$ mzscheme -t the-file.scm
{x b c}
To do the latter:
$ cat the-other-file.scm
#lang scheme
(require scheme/mpair)
(define a-list (list->mlist '(a b c)))
(set-mcar! a-list 'x)
(display a-list)
$ mzscheme -t the-other-file.scm
{x b c}
If you want to do this within DrScheme, select the Module language from
the menu in the lower left corner and place the contents of either
the-file.scm or the-other-file.scm in the definitions window. Hit Run.
David