[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MIT-Scheme-devel] tied in knots with environments

From: David Gray
Subject: Re: [MIT-Scheme-devel] tied in knots with environments
Date: Tue, 1 Feb 2011 14:39:40 +0200

Thanks for all the help clearing this stuff up. One other mistake I made
was that I assumed the ScmUtils was bound to the user-initial-environment
but when I looked into the source code it's the user-generic-environment, hence the initial
knot tying. 
So I ended up with a small dance across the environments a la point 2 from Joe's email.
Also if anyone has a need to plot stuff or call the odd python command I included it.
(define pin (windows-procedure (initpy) int (find-module "Python26.dll") "Py_Initialize"))
;init python
(define prun (windows-procedure (runpy (code string)) int (find-module "Python26.dll") "PyRun_SimpleString"))

(define (list->python-string s)
      (string-append "[" (string-replace (string-trim (with-output-to-string
                                                                           (lambda ()
                                                                               (write s)))
                                                                       char-set:numeric) #\space #\,) "]"))
; init plot lib
(prun "import matplotlib.pyplot as p")
(define (plot x y)
     (prun (string-append "x = " (list->python-string x)))
     (prun (string-append "y = " (list->python-string y)))
     (prun "p.plot (x,y,color='green',lw=2)")
     (prun ""))

in *scheme*:
(load "~/plot.scm" (->environment '(win32)))
(define (plot x y)
     ((access plot (->environment '(win32))) x y))
(define x (iota 20))
(define y (map square plot))
(plot x y) ; as many times as you like

reply via email to

[Prev in Thread] Current Thread [Next in Thread]