next up previous contents
Next: The model of environment Up: Description of the most Previous: The evaluator   Contents

The arithmetical networks

This step is where the work on arithmetical networks really starts. The expression '(= v (* (* pi (sqr 15)) h) is split into various parts, depending on the nature of the elements. This occurs using a conditional function close to the one used previously in the evaluator. Here is an excerpt of this function:

(define (prefix->arinet expr env)
  (let ((current (first expr)))
    (if (atom? current)
              (cond ((ari-number? current) (ari-eval-number current env))
                    ((ari-equation? current) (ari-eval-equation expr env))
                    ((ari-1ary? current) (ari-eval-1ary expr env))
                    ((ari-2ary? current) (ari-eval-2ary expr env))
                    ((ari-module? current) (ari-eval-module expr env))
                    ((ari-variable? current) 
                     (ari-eval-variable current env))))))

As the car of our expression is = the line ((ari-equation? current) (ari-eval-equation expr env)) is true.

This conduce us to the following code:

(define (ari-eval-equation expr env)
  (equalizer (prefix->arinet (left-expr expr) env)
             (prefix->arinet (right-expr expr) env)))

which is a recursive process sending both sides of the equation to prefix_to_arinet again. When evaluating the left side (i.e V) the function detects a variable and drives us to this part of code:

(define (ari-eval-variable variable env)
(lookup-variable-value variable env))

An interesting excerpt as it calls another main part of AriNET:



dominique 2003-06-02