# Re: OT Why Am I doing this?

Ken Tilton <kennytilton@xxxxxxxxxxxxx> writes:

Frank Goenninger DG1SBG wrote:
Ken Tilton <kennytilton@xxxxxxxxxxxxx> writes:

This thread is about, gosh, what is the structure isomorphic to --4
in its mathematical abstractitude? We know 3-2-1 is (3-2)-1
mathematically, so ((- 3 2) 1) is a nice representation of that for
the math engine. And I had gone with (- (- 4)) for --4 (which is
right, it seems) but the thread started because I scared myself with a
false commandment "Thine trees shalt always descend to the
left". Rubbish, thine trees shalt always reflect what they are
modelling.

Right. So why not model

x - -4

as

"Variable x minus the number -4. This means substracting a negative
number. We calculate this as adding the absolute value of the number
-4, which equals to 4. So we get

x + 4."

OK, so -4 is atomic, in the class <number> (using anglys to denote
class). Super.

as it *should* be interpreted by the kids in any case? Translating
that into a data representation then would for me look like

(- x y) with y being bound to -4. This requires recognizing the token
-4 as a number.

Parsing

-4^2

then is

"We see the power operator here. This binds stronger than the minus
sign. Hence we get

- 4^2

which is the number -16."

OK, so now the minus sign is separate from the four, and -4 is either
(a) of class <minus-sign> a subclass of <sign> a subclass of
<operator> and has a slot <operands> populate by 4, a <number>, or
(b) the silliness I have, the operator signed applied to two operands,
a minus sign and a number 4.

What happened to atomic -4?

Hmm - maybe a data-flow driven change? ;-)

Let's see:

(defmd user-input ()
(changed :cell :ephemeral)
token-list
:token-list (c-in nil)
:changed (c-in nil))

(defmd token ()
token-content
token-type

:token-type (c? (analyze-token (^token-content)))
:token-content (c-in nil))

(defobserver changed ((self user-input))
(when new-value
(^rescan)))

(defmethod rescan ((self user-input))

... parse user input from left to right.
During this process tokens are re-generated according to algebra
rules. This is means deleting and creating tokens afresh - maybe
even for every single change of user input. Result will be that each
token is assigned a class depending on content analysis.
"-4" will be seen as a number. etc.

(values))

(defmethod analyze-token ((self token))

... analyze content and assign type/class value.

(values))

So they hit - and I have a sign instance, then they hit 4 and the
minus instance goes away and I have a number instance (value -4) and
then they hit the ^ key to start an exponent and I suddenly have three
instances (-, 4, and a ^ awaiting its exponent), then they hit
backspace and whoops there it is, back to one instance, -4 <number>?

Methinks the components of -4 and -4^2 need to be the same in re the
minus sign and the 4, God does not play change-class with the
universe.

No? Who knows? Seriously: This is your requirement! Deal with it! ;-)

Of course you all know this yourself. So, I just wrote this to check
if I understood your problem and your coding approach correctly - I
will have to deal with something similar down my own project...

The code will tell you if you have taken a wrong turn, it will be hard
to write.

My sketch above of course is just a showing off of the underlying idea
but as you're the Cells Master of The Universe this is, I know it, a
matter of hours for you ...

kt

Frank

--

Frank Goenninger

http://www.goenninger.net
frgo(at)mac(dot)com

"Don't ask me! I haven't been reading comp.lang.lisp long enough to
really know ..."
.

## Relevant Pages

• Re: OT Why Am I doing this?
... thine trees shalt always reflect what they are ... "Variable x minus the number -4. ... This is means deleting and creating tokens afresh - maybe ... but as you're the Cells Master of The Universe this is, I know it, a ...
(comp.lang.lisp)
• Re: OT Why Am I doing this?
... thine trees shalt always reflect what they are ... "Variable x minus the number -4. ... :token-content ) ... During this process tokens are re-generated according to algebra ...
(comp.lang.lisp)
• Re: OT Why Am I doing this?
... thine trees shalt always reflect what they are ... "Variable x minus the number -4. ... that into a data representation then would for me look like ... tokens. ...
(comp.lang.lisp)
• Re: Excel Math Bug
... > tokens for numeric sign and minus operator. ... The numeric sign character is ... > signs in numeric tokens and unary and 'diadic' minus. ...
(microsoft.public.excel.programming)
• Re: Excel Math Bug
... >Precedence of operations is stated in the help. ... tokens for numeric sign and minus operator. ... The numeric sign character is ... signs in numeric tokens and unary and 'diadic' minus. ...
(microsoft.public.excel.programming)