[racket] Using Maxima fra Racket
Hi All,
I am trying to send commands from Racket to Maxima (algebra system).
Here is a normal interaction with Maxima in the terminal:
soegaard$ /Applications/Maxima.app/Contents/Resources/maxima.sh
Maxima 5.25.1 http://maxima.sourceforge.net
using Lisp SBCL 1.0.47
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) 1+2;
(%o1) 3
(%i2)
After displaying the welcome message, Maxima display the prompt "(%i1) ".
The I entered 1+2;<enter>.
Maxima then evaluated the expression and printed the line beginning with
(%o1).
Maxima has an option -s <port> that makes Maxima listen on a give port.
I have used this to write the following:
#lang racket
(require racket/tcp)
(define PORT 8082)
(let ([listener (tcp-listen PORT 1 #t)])
(process (format "/Applications/Maxima.app/Contents/Resources/maxima.sh
-s ~a >/dev/null" PORT))
(let-values ([(in out) (tcp-accept listener)])
(for ([i (in-range 6)]) ; there are 6 lines in the welcome
message
(display (read-line in))
(newline))
(display "prompt:\n")
(write (read in)) ; this displays the prompt (%i1)
(newline)
(write (read-char in)) ; eat whitespace
(newline)
(display "Prompt read correctly.\n")
(display "Sending command to Maxima.\n")
(display "1+2;\n" out) (flush-output out)
(display "Wait, before readin result.\n")
(sleep 1)
(display "Read and print the result one character at a time.\n")
(for ([i (in-range 6)])
(display (peek-char in)) (display "."))))
This gives the following output when run in DrRacket:
pid=15314
Maxima 5.25.1 http://maxima.sourceforge.net
using Lisp SBCL 1.0.47
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
prompt:
(%i1)
#\space
Prompt read correctly.
Sending command to Maxima.
Wait, before readin result.
Read and print the result one character at a time.
(and then nothing is printed)
My problem is that I don't get any output back.
I have a feeling I am missing something obvious - but what?
--
Jens Axel Søgaard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120308/44b6f363/attachment.html>