ex11 - Expected output + function-meanings

LorenzB
Windoof-User
Windoof-User
Beiträge: 28
Registriert: 1. Sep 2015 12:27

ex11 - Expected output + function-meanings

Beitrag von LorenzB » 31. Jan 2018 15:29

Hello,

I have four questions:
When a command is redone it operates on the same expression it operated on the first time. You must make sure that the current field of a Formula really is part of the Formula, i.e. it is reachable from the root Expression.
Does that mean, that we have to store the expression it operated the first time or that we can assume it's the same expression as the first time?
The following selection of (3 + 4) is not tracked by the CommandHistory.

Code: Alles auswählen

if (c.isInstanceOf[InsertPow]) {
  f.current = f.findParentOf(f.current).get
}
So the result of redoing the InsertPow after undoing can produce
((x * (2 + ((((3 + 4) * (3 + 4)) * (3 + 4)) * (3 + 4)))) + []) - (in the first case)
or
((x * (2 + (3 + (((4 * 4) * 4) * 4)))) + []) - (in the second case, where the selection of (3 + 4) has not been tracked and 4 is still selected).
Which on is the desired result?


After redoing everything, there are 3 steps undone (which is InsertPow(f, 4), ChooseNextPlaceholder(f), ReplaceWithNumber(f, 5), I guess).
After that there is just one placeholder left, in both cases right?!
Now there is Number(5) replaced two times, which for me doesn't make any sense. Are the assumptions I made correct?
Is this the new formula? ((x * (2 + (3 + 4))) + 5)
Maybe you can just tell us the expected results of evaluate:
48065, 48065, 185? or 48065, 5225, 185? or something else?


chooseNextPlaceholder vs. findNextPlaceholder:
I guess choose sets current to findNextPlaceholder.get? if there is a next placeholder it returns true, otherwise false? Right?


def addCommand(c: Command): Unit:
What is the usecase of this function? I guess adding a Command without executing doesn't make sense?!


Thank you!

meichholz
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 167
Registriert: 30. Mär 2016 08:28

Re: ex11 - Expected output + function-meanings

Beitrag von meichholz » 1. Feb 2018 13:43

Hi,
LorenzB hat geschrieben:
31. Jan 2018 15:29
Does that mean, that we have to store the expression it operated the first time
Yes.
LorenzB hat geschrieben:
31. Jan 2018 15:29
After redoing everything, there are 3 steps undone (which is InsertPow(f, 4), ChooseNextPlaceholder(f), ReplaceWithNumber(f, 5), I guess).
After that there is just one placeholder left, in both cases right?!
Now there is Number(5) replaced two times, which for me doesn't make any sense. Are the assumptions I made correct?
Is this the new formula? ((x * (2 + (3 + 4))) + 5)
Maybe you can just tell us the expected results of evaluate:
48065, 48065, 185? or 48065, 5225, 185? or something else?
The result should be the same if all commands are undone and redone.
LorenzB hat geschrieben:
31. Jan 2018 15:29
chooseNextPlaceholder vs. findNextPlaceholder:
I guess choose sets current to findNextPlaceholder.get? if there is a next placeholder it returns true, otherwise false? Right?
Yes.
LorenzB hat geschrieben:
31. Jan 2018 15:29
def addCommand(c: Command): Unit:
What is the usecase of this function? I guess adding a Command without executing doesn't make sense?!
You can consider addCommand as a helper method for addAndExecCommand().

Best,
Matthias

LorenzB
Windoof-User
Windoof-User
Beiträge: 28
Registriert: 1. Sep 2015 12:27

Re: ex11 - Expected output + function-meanings

Beitrag von LorenzB » 1. Feb 2018 13:48

Thank you!
meichholz hat geschrieben:
1. Feb 2018 13:43
The result should be the same if all commands are undone and redone.
Yes, but is it right, that the second replace of 5 has no effect, or am i wrong with expecting just one placeholder beeing left?

meichholz
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 167
Registriert: 30. Mär 2016 08:28

Re: ex11 - Expected output + function-meanings

Beitrag von meichholz » 1. Feb 2018 16:49

Hi,

Yes this is correct, in so far that there is no visible difference. The 5 is replaced with a 5.

Best,
Matthias

Antworten

Zurück zu „Archiv“