Sorry, Greg;
 But it looks like you are eating up a lot of non-MUMPS code just to
figure out what state you are looking for.  A calculator is a subroutine
box.  Each key is a function that operates on a state environment.  All
it takes is to screw up one paren pair and your model becomes a real mess
to debug.  I am not sure what you are trying to get at.

   Well have a great weekend.  Chris

> --- [EMAIL PROTECTED] wrote:
>
>> >
>>   BTW, my interpreter was about 10 lines of MUMPS code and the key
>> assignments were kept in a global and pulled out to be executed.   My
>> model had a slight enhancement over the HP calculator in that it had
>> an
>> N depth stack rather than the 4 level stack that HP calculators had.
>> I
>> don't have the code here (writing this in Greenbelt, MD) but I think
>> I
>> posted it here a year or so ago with the global that holds the key
>> assignments.  When I get back next week, I will re-surface the code
>> and
>> republish it again next week when I get back.
>>
>>     Best wishes;   Chris
>>
>
> Certainly, I could have written a concise interpreter like that if that
> was what I was after. The point isn't just being able to evaluate RPN
> (or even infix) arithmetic expressions, but to create a general
> evaluator capable of emitting the necessary instructions to carry out a
> computation and then execute them. Basic arithmetic operation were
> among the first things I implemented. I can't demonstrate control flow
> (if, while etc.) right now because I haven't gotten that far (yet).
>
> Right now, the evaluator does a multi-way branch when processing an
> operator (like "+"):
>
> (define (evaluate-list l)
>   (if (application? l)
>       (cond
>         ((quoted-expression? l) (cadr l))
>         ((list-expression? l) (list 2 (cdr l)))
>         ((is-addition? l) (apply internal-add (map evaluate (cdr l))))
>         ((is-subtraction? l) (apply internal-subtract (map evaluate
> (cdr l))))
>         ((is-multiplication? l) (apply internal-multiply (map evaluate
> (cdr l))))
>         ((is-division? l) (apply internal-divide (map evaluate (cdr
> l))))
>         (else
>          (list 11 "#<void>")))
>       (begin
>         (display-message "invalid function application")
>         (list 11 "#<void>"))))
>
> But it is likely that I'll change this in the next version so that all
> functions (including built in operations) are looked up in the
> environment (symbol table), so the above will become (roughly
>
> (apply f (map evaluate arguments))
>
> In other words, apply evaluate to each of the function arguments
> (creating a list), and then apply the function f to that list. In
> words: this is a strict evaluator that recursively evaluates each
> argument to a function, finally applying the function to the resulting
> values.
>
>
> ===
> Gregory Woodhouse  <[EMAIL PROTECTED]>
> "All truth passes through three stages: First, it is ridiculed.
> Second, it is violently opposed. Third, it is accepted as
> being self-evident."
> --Arthur Schopenhauer
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Hardhats-members mailing list
> Hardhats-members@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hardhats-members
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Hardhats-members mailing list
Hardhats-members@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hardhats-members

Reply via email to