Hello.

I found your E-mail on the newsgroup Scheme. I'm a french

student in computer science (including the Scheme language) and

I'm wondering if you could help me on this problem:

It's about the binary trees of algebric expressions.

Suppose we have this Data Abstract Type:

(define (make-tree R Lt Rt)

(list R Lt Rt))

(define (leaf? t)

(or (number? t) (symbol? t)))

(define (root T)

(if (leaf? T)

T

(car T)))

(define (left-son T)

(if (leaf? T)

(error T "no left son")

(cadr T)))

(define (right-son T)

(if (leaf? T)

(error T "no right son")

(caddr T)))

(define (leaf T)

(if (leaf? T)

(list T)

(append (leaf (left-son T))

(leaf (right-son T)))))

Well now say we have this programm (I hope it is correct):

(define (tree->postfix tree)

(if (leaf? tree)

(list tree)

(append (tree->postfix (left-son tree))

(tree->postfix (right-son tree))

(list (root tree))))))

This function takes a binary tree of algebric expressions like that:

+

* Y

X 2

it could be define like that

->(define tree

(make-tree '+ (make-tree '* 'X 2) 'Y))

tree

->tree

(+ (* X 2) Y)

The result of the function tree->postfix if we take the example would be:

-> (tree->postfix tree)

(2 X * Y +)

In fact this function returns the flat list containing all objects encountered

during the postfix journey of TREE.

At last my question: I wish I would have the reciprocal function such that

(postfix->tree tree) => (compose postfix->tree tree->postfix)=id

In fact this function "set back" the brackets in a plane list.

In our example we should have:

(postfix->tree '(2 X * Y +)) -> (+ (* X 2) Y)

Thank you so much for an answer!

P.S: I'm looking for information about the statement of a program whose

could draw geometric figures whith only a ruler and a pair of compasses.

The interface uses windows and I think we have to define a new syntax

to enable the user to do that for example:

->(leaf)

Windows open a small window

->(draw (straight-line A B))

randomly a line is drawn between A and B.

Any information would be wonderful :)

Bye

Thank you